TinyGo and Vial keyboard for MacroPad
Compile Go firmware for the twelve-key MacroPad, use its encoder for volume, and remap the keyboard through Vial instead of editing CircuitPython profiles.
View original project ↗What you’re building
sago35's tinygo-keyboard includes a dedicated Adafruit MacroPad RP2040 target: native USB keyboard firmware written in Go, with twelve GPIO keys, a rotary encoder, OLED feedback and per-key RGB responses. The supplied map sends the 1 through 9 keys followed by the A, B and C keys; letter case follows the host Shift/Caps Lock state. Turning the encoder sends volume down or up. A pressed key lights its LED and the OLED displays its key number. The example also loads a Vial keyboard definition, so the project is useful for experimenting with host-side key remapping rather than maintaining a folder of CircuitPython macros. The library supports layers, macros, modifier keys and combos; the MacroPad example includes A+B and A+B+C combos. It imports Japanese keycodes, so check punctuation and modifiers against the host keyboard layout before adapting it. This is replacement firmware, not an add-on to Adafruit Hotkeys: back up CIRCUITPY first and expect to reflash the MacroPad-specific CircuitPython UF2 to return to that workflow. This source revision declares Go 1.26.0 and uses TinyGo's RP2040 toolchain; an old TinyGo installation may not accept those dependencies. Keep the repository revision and compiler versions together. The API is not fixed, and this target is a development starting point rather than a finished set of application shortcuts. Its sample registers the two encoder directions, not an encoder-push action; do not assume the Hotkeys profile-selection behavior carries over.
Key steps
- Back up code.py, the macros folder and libraries from CIRCUITPY before replacing the firmware. Use a USB data cable and keep the MacroPad CircuitPython UF2 available if you want to return to Hotkeys.
- Clone https://github.com/sago35/tinygo-keyboard, select the revision opened by View original project, and open targets/macropad-rp2040. Inspect go.mod before selecting compatible Go and TinyGo versions; this source revision declares Go 1.26.0.
- From the repository root, compile without flashing first: tinygo build --target macropad-rp2040 --size short --stack-size 8kb -o macropad.uf2 ./targets/macropad-rp2040/. Keep the 8kb stack setting used by the project.
- Enter the RP2040 bootloader by holding the encoder BOOT button while pressing and releasing RESET, then release BOOT. Copy macropad.uf2 to the RPI-RP2 drive; do not copy it onto CIRCUITPY.
- Open a blank text editor and test the twelve keys before assigning shortcuts: expect the 1 through 9 keys, then A, B and C (letter case depends on Shift/Caps Lock). Turn the encoder both ways to test host volume, and check the key-number OLED feedback and pressed-key LED response.
- Connect the flashed keyboard in Vial using the desktop app or a WebHID-compatible browser. Remap one harmless key first and test it in the editor; the target already includes vial.json and its generated keyboard definition.
- When changing the firmware itself, edit targets/macropad-rp2040/main.go. Keep its GPIO mapping and Vial definition aligned, and test the supplied combos separately from ordinary key presses. Check the Japanese keycode import against your host layout.
- If a version change leaves an unusable map, use the repository reset_to_default build tag deliberately: it restores defaults on every reset, so remove it for ordinary persistent remapping. To return to CircuitPython, re-enter RPI-RP2, install the MacroPad CircuitPython UF2 and restore the backed-up files.
