~jack/misc

8f3f48185491b668b642af035710c770d0869524 — Jack Kelly 4 months ago 3a45755
Add ergodox firmware
M .build.yml => .build.yml +3 -0
@@ 14,6 14,9 @@ tasks:
  - codeworld-raycaster: |
      cd misc/codeworld-raycaster
      nix-build --no-out-link
  - ergodox: |
      cd misc/ergodox
      nix-build --no-out-link
  - metscrape: |
      cd misc/metscrape
      nix-build --no-out-link

A ergodox/README.md => ergodox/README.md +20 -0
@@ 0,0 1,20 @@
# Ergodox Firmware

This repo holds nix scripts to build firmware for my [Infinity
Ergodox](https://input.club/devices/infinity-ergodox/). The kiibohd
repos have broken Infinity Ergodox support for some time, and [nobody
seems to care](https://github.com/kiibohd/controller/issues/204#issuecomment-315766171).

This means that I needed specific checkouts of the `controller` and
`kll` repos, plus a patch to fix semantics of `inline` functions with
modern GCC. This is the sort of thing [Nix](https://nixos.org/nix/)
excels at.


## Building and Flashing

`nix build` will create binaries for each half under
`./result`. `nix-shell` will then give you a shell with `dfu-util`
available; from there you can run `sudo dfu-util -D
result/left.dfu.bin` or `sudo dfu-util -D result/right.dfu.bin` to
flash each half of the board.

A ergodox/config/MDErgo1-Default-0.kll => ergodox/config/MDErgo1-Default-0.kll +85 -0
@@ 0,0 1,85 @@
Name = "MDErgo1";
Layout = "Default";
Base = "Blank";
Version = "0.1";
Author = "HaaTa (Jacob Alexander) 2015";
KLL = "0.5";
Date = "2015-09-12";
Generator = "KIICONF 0.2";

U"ESC" : U"ESC";
U"5" : U"5";
U"4" : U"4";
U"3" : U"3";
U"2" : U"2";
U"1" : U"1";
U"EQUALS" : U"BACKTICK";
U"FUNCTION1" : U"FUN5";
U"T" : U"T";
U"R" : U"R";
U"E" : U"E";
U"W" : U"W";
U"Q" : U"Q";
U"BACKSLASH" : U"TAB";
U"G" : U"G";
U"F" : U"F";
U"D" : U"D";
U"S" : U"S";
U"A" : U"A";
U"TAB" : U"LCTRL";
U"LALT" : U"]";
U"LCTRL" : U"[";
U"FUNCTION2" : U"FUN4";
U"B" : U"B";
U"V" : U"V";
U"C" : U"C";
U"X" : U"X";
U"Z" : U"Z";
U"LSHIFT" : U"LSHIFT";
U"HOME" : U"DELETE";
U"END" : U"FUN6";
U"DELETE" : U"INSERT";
U"BACKSPACE" : U"BACKSPACE";
U"FUNCTION5" : U"LALT";
U"FUNCTION4" : U"LGUI";
U"FUNCTION3" : U"FUN3";
U"BACKTICK" : U"FUN2";
U"LGUI" : U"FUN1";
U"FUNCTION6" : U"CAPSLOCK";
U"6" : U"6";
U"7" : U"7";
U"8" : U"8";
U"9" : U"9";
U"0" : U"0";
U"MINUS" : U"MINUS";
U"LBRACE" : U"FUN5";
U"Y" : U"Y";
U"U" : U"U";
U"I" : U"I";
U"O" : U"O";
U"P" : U"P";
U"RBRACE" : U"BACKSLASH";
U"H" : U"H";
U"J" : U"J";
U"K" : U"K";
U"L" : U"L";
U"SEMICOLON" : U"SEMICOLON";
U"QUOTE" : U"QUOTE";
U"RALT" : CONS"VOLUMEDOWN";
U"RCTRL" : CONS"VOLUMEUP";
U"FUNCTION7" : U"FUN4";
U"N" : U"N";
U"M" : U"M";
U"COMMA" : U"COMMA";
U"PERIOD" : U"PERIOD";
U"SLASH" : U"SLASH";
U"RSHIFT" : U"RSHIFT";
U"PAGEUP" : CONS"MUTE";
U"PAGEDOWN" : U"FUN7";
U"ENTER" : U"ENTER";
U"SPACE" : U"SPACE";
U"LEFT" : U"RALT";
U"DOWN" : U"RGUI";
U"UP" : U"FUN3";
U"RIGHT" : U"FUN2";
U"RGUI" : U"FUN1";

A ergodox/config/MDErgo1-Default-1.kll => ergodox/config/MDErgo1-Default-1.kll +40 -0
@@ 0,0 1,40 @@
Name = "MDErgo1";
Layout = "Default";
Base = "Blank";
Version = "0.1";
Author = "HaaTa (Jacob Alexander) 2015";
KLL = "0.5";
Date = "2015-09-12";
Generator = "KIICONF 0.2";

U"T" : '%';
U"R" : '$';
U"E" : '#';
U"W" : '@';
U"Q" : '!';
U"BACKSLASH" : '~';
U"F" : U"END";
U"D" : U"PAGEDOWN";
U"S" : U"PAGEUP";
U"A" : U"HOME";
U"MINUS" : '+';
U"Y" : '^';
U"U" : '&';
U"I" : '*';
U"O" : '(';
U"P" : ')';
U"RBRACE" : '_';
U"H" : U"LEFT";
U"J" : U"DOWN";
U"K" : U"UP";
U"L" : U"RIGHT";
U"QUOTE" : U"EQUALS";
U"V" : '[';
U"B" : ']';
U"N" : '{';
U"M" : '}';

U"SEMICOLON" : ':';
U"COMMA" : '<';
U"PERIOD" : '>';
U"SLASH" : '?';

A ergodox/config/MDErgo1-Default-2.kll => ergodox/config/MDErgo1-Default-2.kll +53 -0
@@ 0,0 1,53 @@
Name = "MDErgo1";
Layout = "Default";
Base = "Blank";
Version = "0.1";
Author = "HaaTa (Jacob Alexander) 2015";
KLL = "0.5";
Date = "2015-09-12";
Generator = "KIICONF 0.2";

U"C" : 'const';
U"E" : 'Either';
U"F" : 'fmap';
U"M" : 'Maybe';
U"N" : 'Nothing';
U"J" : 'Just';
U"H" : 'Left';
U"L" : 'Right';

U"T" : 'otherwise';
U"P" : 'pure';
U"Q" : 'undefined';
U"Z" : 'mempty';

U"R" : '<$>';
U"4" : '>$<';

U"U" : '<&>';

U"MINUS" : '<>';
U"X" : '><';

U"RBRACE" : '<|>';

# <* is seldom used and better typed with I, backspace.
U"I" : '<*>';
U"O" : '*>';

# >* is typed with 8, backspace.
U"8" : '>*<';
U"9" : '*<';

U"V" : '=<<';
U"B" : '>>=';

U"SEMICOLON" : '::';
U"QUOTE" : '=>';
U"COMMA" : '<-';
U"PERIOD" : '->';

U"LCTRL" : '{-';
U"LALT" : '-}';
U"RALT" : '{-#', U"SPACE";
U"RCTRL" : U"SPACE", '#-}';

A ergodox/config/MDErgo1-Default-3.kll => ergodox/config/MDErgo1-Default-3.kll +21 -0
@@ 0,0 1,21 @@
Name = "MDErgo1";
Layout = "Default";
Base = "Blank";
Version = "0.1";
Author = "HaaTa (Jacob Alexander) 2015";
KLL = "0.5";
Date = "2015-09-12";
Generator = "KIICONF 0.2";

U"2" : 'jack@jackkelly.name';
U"W" : '@';
U"MINUS" : '--', U"SPACE",  'Jack';

U"S" : 'Shut', U"SPACE", 'up', U"SPACE", 'slackbot.', U"ENTER";

U"E" : 'example.com';
U"G" : 'gmail.com';
U"L" : 'localhost';

U"N" : U"LCTRL" + U"LSHIFT" + U"U", '2013', U"SPACE";
U"M" : U"LCTRL" + U"LSHIFT" + U"U", '2014', U"SPACE";

A ergodox/config/MDErgo1-Default-4.kll => ergodox/config/MDErgo1-Default-4.kll +38 -0
@@ 0,0 1,38 @@
Name = "MDErgo1";
Layout = "Default";
Base = "Blank";
Version = "0.1";
Author = "HaaTa (Jacob Alexander) 2015";
KLL = "0.5";
Date = "2015-09-12";
Generator = "KIICONF 0.2";

U"ESC" : U"F11";
U"5" : U"F5";
U"4" : U"F4";
U"3" : U"F3";
U"2" : U"F2";
U"1" : U"F1";
U"FUNCTION6" : U"F12";
U"6" : U"F6";
U"7" : U"F7";
U"8" : U"F8";
U"9" : U"F9";
U"0" : U"F10";

U"C" : 'case', U"SPACE";
U"L" : 'class', U"SPACE";
U"D" : 'data', U"SPACE";
U"E" : 'default', U"SPACE";
U"V" : 'deriving', U"SPACE";
U"F" : 'family', U"SPACE";
U"A" : 'forall', U"SPACE";
U"R" : 'foreign', U"SPACE";
U"H" : 'hiding', U"SPACE";
U"X" : 'infix';
U"I" : 'instance', U"SPACE";
U"M" : 'module', U"SPACE";
U"N" : 'newtype', U"SPACE";
U"P" : 'proc', U"SPACE";
U"T" : 'type', U"SPACE";
U"W" : 'where';

A ergodox/config/MDErgo1-Default-5.kll => ergodox/config/MDErgo1-Default-5.kll +11 -0
@@ 0,0 1,11 @@
Name = "MDErgo1";
Layout = "Default";
Base = "Blank";
Version = "0.1";
Author = "HaaTa (Jacob Alexander) 2015";
KLL = "0.5";
Date = "2015-09-12";
Generator = "KIICONF 0.2";

U"EQUALS" : flashMode();
U"MINUS" : flashMode();

A ergodox/config/MDErgo1-Default-6.kll => ergodox/config/MDErgo1-Default-6.kll +37 -0
@@ 0,0 1,37 @@
Name = "MDErgo1";
Layout = "Default";
Base = "Blank";
Version = "0.1";
Author = "HaaTa (Jacob Alexander) 2015";
KLL = "0.5";
Date = "2015-09-12";
Generator = "KIICONF 0.2";

U"I" : 'import', U"SPACE";
U"Q" : 'qualified', U"SPACE";

U"C" : 'Control.';
U"D" : 'Data.';
U"R" : 'RaaP.';

U"A" : 'Applicative';
U"W" : 'Arrow';
U"B" : 'ByteString';
U"F" : 'Foldable';
U"U" : 'Functor';
U"H" : 'Hash';
U"L" : 'Lens';
U"Y" : 'Maybe';
U"P" : 'Map';
U"M" : 'Monad';
U"N" : 'Monoid';
U"G" : 'Semigroup';
U"S" : 'Set';
U"T" : 'Traversable';
U"X" : 'Text';
U"V" : 'Vector';

U"8" : '.Char8';
U"O" : '.Contravariant';
U"K" : '.Strict';
U"Z" : '.Lazy';

A ergodox/config/MDErgo1-Default-7.kll => ergodox/config/MDErgo1-Default-7.kll +32 -0
@@ 0,0 1,32 @@
Name = "MDErgo1";
Layout = "Default";
Base = "Blank";
Version = "0.1";
Author = "HaaTa (Jacob Alexander) 2015";
KLL = "0.5";
Date = "2015-09-12";
Generator = "KIICONF 0.2";

U"C" : 'class', U"SPACE";
U"D" : 'deriving', U"SPACE";
U"I" : 'instance', U"SPACE";
U"W" : 'where';
U"O" : '(';
U"P" : ')';
U"," : U",", U"SPACE";

U"A" : 'Applicative';
U"Z" : 'As';
U"B" : 'Bounded';
U"E" : 'Eq';
U"F" : 'Foldable';
U"U" : 'Functor';
U"G" : 'Generic';
U"X" : 'Has';
U"H" : 'Hashable';
U"R" : 'Ord';
U"S" : 'Show';
U"M" : 'Monad';
U"N" : 'Monoid';
U"T" : 'Traversable';
U"Y" : 'Typeable';

A ergodox/config/MDErgo1-Default-8.kll => ergodox/config/MDErgo1-Default-8.kll +29 -0
@@ 0,0 1,29 @@
Name = "MDErgo1";
Layout = "Default";
Base = "Blank";
Version = "0.1";
Author = "HaaTa (Jacob Alexander) 2015";
KLL = "0.5";
Date = "2015-09-12";
Generator = "KIICONF 0.2";

U"7" : U"NUMLOCK";
U"8" : U"P/";
U"9" : U"P*";
U"0" : U"P-";
U"U" : U"P7";
U"I" : U"P8";
U"O" : U"P9";
U"P" : U"P+";
U"J" : U"P4";
U"K" : U"P5";
U"L" : U"P6";
U"SEMICOLON" : U"P+";
U"M" : U"P1";
U"COMMA" : U"P2";
U"PERIOD" : U"P3";
U"SLASH" : U"PENTER";
U"LEFT" : U"P0";
U"DOWN" : U"P0";
U"UP" : U"P.";
U"RIGHT" : U"PENTER";

A ergodox/config/ergodox-custom.bash => ergodox/config/ergodox-custom.bash +101 -0
@@ 0,0 1,101 @@
#!/usr/bin/env bash
# This is a build script template
# These build scripts are just a convenience for configuring your keyboard (less daunting than CMake)
# Jacob Alexander 2015-2016



#################
# Configuration #
#################

######## Left Side ########

# Feel free to change the variables in this section to configure your keyboard

BuildPath="ICED-L"

## KLL Configuration ##

# Generally shouldn't be changed, this will affect every layer
BaseMap="scancode_map leftHand slave1 rightHand"

# This is the default layer of the keyboard
# NOTE: To combine kll files into a single layout, separate them by spaces
# e.g.  DefaultMap="mylayout mylayoutmod"
DefaultMap="MDErgo1-Default-0 lcdFuncMap"

# This is where you set the additional layers
# NOTE: Indexing starts at 1
# NOTE: Each new layer is another array entry
# e.g.  PartialMaps[1]="layer1 layer1mod"
#       PartialMaps[2]="layer2"
#       PartialMaps[3]="layer3"
PartialMaps[1]="MDErgo1-Default-1 lcdFuncMap"
PartialMaps[2]="MDErgo1-Default-2 lcdFuncMap"
PartialMaps[3]="MDErgo1-Default-3 lcdFuncMap"
PartialMaps[4]="MDErgo1-Default-4 lcdFuncMap"
PartialMaps[5]="MDErgo1-Default-5 lcdFuncMap"
PartialMaps[6]="MDErgo1-Default-6 lcdFuncMap"
PartialMaps[7]="MDErgo1-Default-7 lcdFuncMap"
#PartialMaps[8]="MDErgo1-Default-8 lcdFuncMap"



##########################
# Advanced Configuration #
##########################

# Don't change the variables in this section unless you know what you're doing
# These are useful for completely custom keyboards
# NOTE: Changing any of these variables will require a force build to compile correctly

# Keyboard Module Configuration
ScanModule="Infinity_Ergodox"
MacroModule="PartialMap"
OutputModule="pjrcUSB"
DebugModule="full"

# Microcontroller
Chip="mk20dx256vlh7"

# Compiler Selection
Compiler="gcc"



########################
# Bash Library Include #
########################

# Shouldn't need to touch this section

# Check if the library can be found
if [ ! -f cmake.bash ]; then
        echo "ERROR: Cannot find 'cmake.bash'"
        exit 1
fi

# Load the library
source cmake.bash



#########################
# Re-run for right side #
#########################

######## Right Side ########

# Feel free to change the variables in this section to configure your keyboard

BuildPath="ICED-R"

## KLL Configuration ##

# Only changing the basemap (everything else is the same)
# Generally shouldn't be changed, this will affect every layer
BaseMap="defaultMap rightHand slave1 leftHand"

# Load the library (starts the build)
source cmake.bash

A ergodox/config/scancode_map.kll => ergodox/config/scancode_map.kll +82 -0
@@ 0,0 1,82 @@
Name = MDErgo1;
Version = 0.2;
Author = "HaaTa (Jacob Alexander) 2014-2015";
KLL = 0.3c;

# Modified Date
Date = 2015-08-15;

########
# NOTE #
########

# Default ScanCode mappings are in rightHand.kll and leftHand.kll
# To change which node you are refering to, set the ConnectId variable
# i.e.
# ConnectId = 0;
# S0x02 : U"A"; # Sets scan code 0x02 on keyboard connected to USB
# ConnectId = 1;
# S0x02 : U"B"; # Sets scan code 0x02 on the first slave node
#
# ConnectId may be set in the previously parsed kll file
# In general you shouldn't have to worry about setting ConnectId unless you want a single configuration file


#
# Defines available to the MDErgo1 Scan Module
#

# LED Default Enable Mask Override
#
# Each LED is represented by a single bit
# See (http://www.issi.com/WW/pdf/31FL3731C.pdf) for details
ISSILedMask1 = "
        0xFF, 0x00, /* C1-1 -> C1-16 */
        0xFF, 0x00, /* C2-1 -> C2-16 */
        0xFF, 0x00, /* C3-1 -> C3-16 */
        0xFF, 0x00, /* C4-1 -> C4-16 */
        0x3F, 0x00, /* C5-1 -> C5-16 */
        0x00, 0x00, /* C6-1 -> C6-16 */
        0x00, 0x00, /* C7-1 -> C7-16 */
        0x00, 0x00, /* C8-1 -> C8-16 */
        0x00, 0x00, /* C9-1 -> C9-16 */
";

# LED Brightness Override
#
# Each LED channel supports 256 levels (8-bit control)
ISSILedBrightness1 = "
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C1-1 -> C1-16 */
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C2-1 -> C2-16 */
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C3-1 -> C3-16 */
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C4-1 -> C4-16 */
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C5-1 -> C5-16 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C6-1 -> C6-16 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C7-1 -> C7-16 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C8-1 -> C8-16 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C9-1 -> C9-16 */
";

# LCD Backlight Channel Brightness Override
# There are 3 channels, RGB
# In order to get other colors you must mix the 3 colors
# Each channel is a 16-bit register (65536 levels)
# Technically, this means, the backlight is a 48-bit RGB pixel
# In practice, it may be difficult to get color consistency at times if too bright or too dim
#
# Defaults to 6% brightness, white
STLcdBacklightRed   = 0x0FFF;
STLcdBacklightGreen = 0x0FFF;
STLcdBacklightBlue  = 0x0FFF;

# LCD Image Override
#
# The easiest way to generate this data is using the bitmap2Struct.py script in the STLcd folder
# It will output the necessary uint8_t array to set here
#
STLcdDefaultImage = "
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xf0, 0xf0, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x03, 0xff, 0xff, 0xff, 0xff, 0x03, 0x03, 0x83, 0x83, 0x0f, 0x0f, 0x3f, 0x3f, 0x00, 0x00, 0x03, 0x03, 0xff, 0xff, 0xff, 0xff, 0x03, 0x03, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0xf0, 0xf0, 0xfc, 0xfc, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfc, 0xff, 0xff, 0x3f, 0x3f, 0x0f, 0x0f, 0x0f, 0x0f, 0x3f, 0x3f, 0xff, 0xff, 0xfc, 0xfc, 0x00, 0x00, 0xfc, 0xfc, 0xff, 0xff, 0x03, 0x03, 0x03, 0x03, 0xfc, 0xfc, 0xff, 0xff, 0x03, 0x03, 0x00, 0x00, 0xfc, 0xfc, 0xff, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xff, 0xff, 0xfc, 0xfc, 0x00, 0x00, 0x03, 0x03, 0x0f, 0x0f, 0xfc, 0xfc, 0xf0, 0xf0, 0xfc, 0xfc, 0x0f, 0x0f, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xcf, 0xcf, 0xcf, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x06, 0x06, 0x1f, 0x1f, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x0c, 0x0c, 0x0f, 0x0f, 0x03, 0x03, 0x0f, 0x0f, 0x0c, 0x0c, 0x0f, 0x0f, 0x03, 0x03, 0x00, 0x00, 0x03, 0x03, 0x0f, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x03, 0x03, 0x0f, 0x0f, 0x0c, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xcf, 0x3f, 0x3f, 0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0xcf, 0xcf, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x0f, 0x0f, 0x0c, 0x0c, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x0f, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0f, 0x0f, 0x03, 0x03, 0x00, 0x00, 0x0c, 0x0c, 0x0f, 0x0f, 0x03, 0x03, 0x00, 0x00, 0x03, 0x03, 0x0f, 0x0f, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x0c, 0x0f, 0x0f, 0x0f, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x0c, 0x0c, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00,
";

A ergodox/default.nix => ergodox/default.nix +69 -0
@@ 0,0 1,69 @@
{ nixpkgs ? import ./nix/nixpkgs.nix }:
let
  inherit (nixpkgs) pkgs;

  controller = pkgs.fetchFromGitHub {
    owner = "kiibohd";
    repo = "controller";
    rev = "c7fb6d1c3be29de1bcb0b9c7201448e66fb2ca33";
    sha256 = "170fz7qa6zdjs4hgal3v0h6nsh99wnscf6kd467frg5d61lyxr5g";
  };

  kll = pkgs.fetchFromGitHub {
    owner = "kiibohd";
    repo = "kll";
    rev = "2062be08e34430d523b20947e9eb5a3ec3948331";
    sha256 = "0xgg12bsg1gq3jfy7g7qyngaxq2nmzl747w1nr2nb85dvqq1mkad";
  };

  static-inline-patch = builtins.fetchurl {
    url = "https://gist.githubusercontent.com/wailashi/3f4322985c2f752bc8e76e1bfb4a127b/raw/1ecfb2bc999b0c32d6d65906873b190865f45e1b/inline_fix.patch";
    sha256 = "0cwza4cmq7knggwkn8pmw9wmranb2h053i8mn8a61g81r377lnp9";
  };
in
  pkgs.stdenv.mkDerivation rec {
    name = "ergodox-infinity-firmware";
    src = ./config;

    buildInputs = with pkgs; [
      cmake dfu-util gcc-arm-embedded gnumake git
    ];

    patches = [ static-inline-patch ];

    unpackPhase = ''
      cp -R ${controller}/* .
      cp -R ${kll} kll
      chmod -R +w .

      # Fix the interpreters
      sed -i '1c#!${pkgs.bash}/bin/bash' Lib/CMake/sizeCalculator
      sed -i '1c#!${pkgs.bash}/bin/bash' Lib/CMake/writer
      sed -i '1c#!${pkgs.python3}/bin/python3' kll/kll.py

      # Copy our config
      cp -v $src/scancode_map.kll Scan/Infinity_Ergodox
      cp -v $src/ergodox-custom.bash Keyboards
      cp -v $src/MDErgo1-Default-*.kll kll/layouts
    '';

    configurePhase = ":";

    buildPhase = ''
      cd Keyboards
      bash ergodox-custom.bash || true
    '';

    installPhase = ''
      mkdir $out
      cp ICED-L.gcc/kiibohd.dfu.bin $out/left.dfu.bin
      cp ICED-R.gcc/kiibohd.dfu.bin $out/right.dfu.bin
    '';

    meta = with pkgs.stdenv.lib; {
      description = "Firmware for my Infinity Ergodox";
      license = licenses.gpl3;
      maintainers = [ maintainers.endgame ];
      platforms = platforms.all;
    };
  }

A ergodox/nix/nixpkgs.json => ergodox/nix/nixpkgs.json +7 -0
@@ 0,0 1,7 @@
{
  "url": "https://github.com/NixOS/nixpkgs",
  "rev": "0243f4455bb6b6911ccdf663681ca95430bf235e",
  "date": "2019-11-28T13:56:44+01:00",
  "sha256": "0m3az0r10ccjam9w4gcwbxql7rgdyymm3fwbwhga1dafq1vrrrfm",
  "fetchSubmodules": false
}

A ergodox/nix/nixpkgs.nix => ergodox/nix/nixpkgs.nix +8 -0
@@ 0,0 1,8 @@
let
  nixpkgsJson = builtins.fromJSON (builtins.readFile ./nixpkgs.json);
  nixpkgsFunc = import (builtins.fetchTarball (with nixpkgsJson; {
    url = "${url}/archive/${rev}.tar.gz";
    inherit sha256;
  }));
in
  nixpkgsFunc {}

A ergodox/nix/update.bash => ergodox/nix/update.bash +4 -0
@@ 0,0 1,4 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix-prefetch-git

nix-prefetch-git https://github.com/NixOS/nixpkgs > nixpkgs.json

A ergodox/shell.nix => ergodox/shell.nix +7 -0
@@ 0,0 1,7 @@
{ nixpkgs ? import ./nix/nixpkgs.nix }:
let
  inherit (nixpkgs) pkgs;
in
  pkgs.mkShell {
    buildInputs = [ pkgs.dfu-util ];
  }