-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
465f41e
commit d638f2a
Showing
10 changed files
with
154 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
Based on [Matt Sturgeon's config](https://github.com/MattSturgeon/glove80-config) | ||
|
||
# Usage | ||
|
||
## Build firmware | ||
|
||
```sh | ||
nix build | ||
# This will output the firmware file to `/result/glove80.uf2` | ||
nix build | ||
``` | ||
|
||
This will output the firmware file to `/result/glove80.uf2` | ||
|
||
## Flash firmware | ||
|
||
TODO: flash both halves with one script | ||
```sh | ||
# Connect the right half (in bootloader mode) | ||
Run nix run | ||
# Connect the left half (in bootloader mode) | ||
Run nix run | ||
``` | ||
|
||
```sh | ||
# Connect half (in bootloader mode) then run this. repeat this for both halves | ||
nix run | ||
``` | ||
|
||
# Credits | ||
|
||
Layout adapted from [MoErgo's template](https://github.com/moergo-sc/glove80-zmk-config) | ||
Nix flake based on [Matt Sturgeon's config](https://github.com/MattSturgeon/glove80-config) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ inputs, ... }: | ||
{ | ||
perSystem = | ||
{ | ||
config, | ||
pkgs, | ||
system, | ||
... | ||
}: | ||
{ | ||
packages.firmware = | ||
let | ||
firmware = import inputs.glove80-zmk { inherit pkgs; }; | ||
|
||
keymap = ./glove80.keymap; | ||
kconfig = pkgs.writeText "glove80.conf" ""; | ||
|
||
left = firmware.zmk.override { | ||
inherit keymap kconfig; | ||
board = "glove80_lh"; | ||
}; | ||
|
||
right = firmware.zmk.override { | ||
inherit keymap kconfig; | ||
board = "glove80_rh"; | ||
}; | ||
in | ||
firmware.combine_uf2 left right; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
perSystem = | ||
{ | ||
config, | ||
pkgs, | ||
system, | ||
... | ||
}: | ||
{ | ||
# Builds the firmware and copies it to the plugged-in keyboard half | ||
packages.flash = pkgs.writeShellApplication { | ||
name = "flash"; | ||
text = | ||
# sh | ||
'' | ||
set +e | ||
# Disable -u because empty arrays are treated as "unbound" | ||
set +u | ||
# Enable nullglob so that non-matching globs have no output | ||
shopt -s nullglob | ||
# Indent piped input 4 spaces | ||
indent() { | ||
sed -e 's/^/ /' | ||
} | ||
# Platform specific disk candidates | ||
declare -a disks | ||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | ||
# Linux/GNU | ||
# - /run/media/<user>/<disk> | ||
disks=(/run/media/"$(whoami)"/GLV80*) | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
# Mac OSX | ||
# - /Volumes/<disk> | ||
disks=(/Volumes/GLV80*) | ||
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then | ||
# Cygwin or Msys2 | ||
# - /<drive letter> | ||
disks=(/?) | ||
elif (grep -sq Microsoft /proc/version); then | ||
# WSL | ||
# - /mnt/<drive letter> | ||
disks=(/mnt/?) | ||
else | ||
echo "Error: Unable to detect platform!" | ||
echo "OSTYPE=$OSTYPE" | ||
echo "/proc/version" | ||
indent < /proc/version | ||
exit 1 | ||
fi | ||
# Disks that have a matching INFO_UF2 | ||
declare -a matches | ||
for disk in "''${disks[@]}"; do | ||
if (grep -sq Glove80 "$disk"/INFO_UF2.TXT); then | ||
matches+=("$disk") | ||
fi | ||
done | ||
# Assert we found exactly one keyboard | ||
count="''${#matches[@]}" | ||
if [[ "$count" -lt 1 ]]; then | ||
# No matches. Exit | ||
echo "Error: No Glove80 connected!" | ||
exit 1 | ||
elif [[ "$count" -gt 1 ]]; then | ||
# Multiple matches. Print them and exit | ||
echo "Error: $count Glove80s connected. Expected 1!" | ||
for i in "''${!matches[@]}"; do | ||
kb="''${matches[$i]}" | ||
grep --no-filename --color=never Glove80 "$kb"/INFO_UF2.TXT | indent | ||
done | ||
exit 1 | ||
fi | ||
# We have a winner! | ||
kb="''${matches[0]}" | ||
echo "Found keyboard:" | ||
echo "$kb" | ||
indent < "$kb"/INFO_UF2.TXT | ||
echo | ||
# Flash by copying the firmware package | ||
echo "Flashing firmware..." | ||
cp -r "${config.packages.firmware}" "$kb" \ | ||
&& echo "Done!" || echo "Error: Unable to flash firmware!" | ||
''; | ||
}; | ||
}; | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.