I’ve been doing an experiment to see how much difference it would make to switch from row,col
key addressing to using just a single integer to index each key. So, I made changes in a whole lot of modules, but mostly Kaleidoscope-Hardware-Model01 and Kaleidoscope itself. I built a slightly-customized version of the default firmware without AlphaSquare and TestMode, but with Qukeys. Here’s what the builder reports for the program without my “keyaddr” changes:
BOARD_HARDWARE_PATH="/Users/merlin/Documents/Arduino/hardware" /Users/merlin/Documents/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder build-all
Building output/Model01-Firmware/Model01-Firmware (0.0.0-gv1.22-2-gedd0) ...
- Size: firmware/Model01-Firmware/Model01-Firmware-0.0.0-gv1.22-2-gedd0.elf
- Program: 18330 bytes (63.9% Full)
- Data: 1716 bytes (67.0% Full)
…and here’s the same sketch with single-byte addresses:
BOARD_HARDWARE_PATH="/Users/merlin/Documents/Arduino/hardware" /Users/merlin/Documents/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder build-all
Building output/Model01-Firmware/Model01-Firmware (0.0.0-gv1.22-2-gedd0) ...
- Size: firmware/Model01-Firmware/Model01-Firmware-0.0.0-gv1.22-2-gedd0.elf
- Program: 17796 bytes (62.1% Full)
- Data: 1649 bytes (64.4% Full)
That’s 534 bytes smaller in PROGMEM, and 67 fewer bytes in RAM (at least, to start with). It’s only about 3% smaller, but that might make a significant difference in some cases.
Now, it’s not all working quite properly (I didn’t quite get the conversion of the LED matrix correct, so the wrong keys light up in some modes, and I introduced at least one bug in NumPad), but it is mostly working (typing, MouseKeys). For most plugins, the conversion was surprisingly easy to do.
The real downside here is that it’s very difficult to make this change backwards-compatible, because it changes the signature of the eventHandlerHook()
functions for plugins. I think it can be done, but it may require some trickery to get a version of Kaleidoscope that works with both KeyAddr
and (row,col)
plugins – probably a new transitional hook point.