Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15,921 changes: 15,921 additions & 0 deletions hackpads/Hexpad-macropad/CAD/hexpad_assembly.step

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions hackpads/Hexpad-macropad/Firmware/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Firmware

KMK (CircuitPython) firmware for the hexpad macropad — 6 keys + 1 rotary encoder
on a **Seeed XIAO RP2040**. KMK is used because it needs no build toolchain:
you drag files onto the board's USB drive and edit `code.py` to remap keys.

## Files

| File | Purpose |
|------|---------|
| `code.py` | The keymap + wiring. This is the firmware you edit. |

## Flash it (one-time setup)

1. **Put CircuitPython on the XIAO RP2040.**
- Download the XIAO RP2040 build: <https://circuitpython.org/board/seeeduino_xiao_rp2040/>
- Plug the XIAO in. Enter the bootloader: hold **BOOT**, tap **RESET**, release BOOT
(or double-tap RESET). A drive named **RPI-RP2** appears.
- Drag the downloaded `.uf2` onto **RPI-RP2**. It reboots as a drive named **CIRCUITPY**.
2. **Add the KMK library.**
- Download KMK: <https://github.com/KMKfw/kmk_firmware> (green *Code → Download ZIP*).
- Copy the **`kmk/`** folder from that zip to the root of the **CIRCUITPY** drive.
3. **Add this firmware.**
- Copy **`firmware/code.py`** to the root of **CIRCUITPY** (replace the default `code.py`).
- It runs immediately. Press a key / turn the knob to test.

To change keys later: just edit `code.py` on the CIRCUITPY drive and save — it
reloads automatically.

## Default keymap

```
( encoder: turn = volume, press = mute )

[ Copy ] [ Paste ] [ Cut ] <- front row (SW1 SW2 SW3)
[ Undo ] [ Redo ] [ Save ] <- rear row (SW4 SW5 SW6)
```

Edit the `KC.*` entries in `code.py` to remap. Examples are in the comments
there (plain keys, Ctrl/Cmd combos, media keys).

## Pin map (matches the PCB)

Each switch: pin → GND, internal pull-up (press = LOW). No diodes.

| Key | XIAO pin | RP2040 GPIO |
|-----|----------|-------------|
| SW1 | D0 | GPIO26 |
| SW2 | D1 | GPIO27 |
| SW3 | D2 | GPIO28 |
| SW4 | D3 | GPIO29 |
| SW5 | D6 | GPIO0 |
| SW6 | D7 | GPIO1 |
| Encoder A | D8 | GPIO2 |
| Encoder B | D9 | GPIO4 |
| Encoder push | D10 | GPIO3 |
| Encoder common / switch GND | GND | — |

`code.py` uses the `board.D#` names, so it stays correct regardless of the
underlying GPIO numbers.

## Prefer QMK?

QMK also runs on the RP2040 but needs a compile toolchain (`qmk` CLI, a
`info.json` declaring `direct` pins for the 6 keys + an `encoders` block, and a
`keymap.c`). KMK is recommended here for the no-build workflow; ask if you want
the QMK variant instead.
52 changes: 52 additions & 0 deletions hackpads/Hexpad-macropad/Firmware/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""KMK firmware for the hexpad macropad (Seeed XIAO RP2040).

6 keys (3x2) direct-wired to GPIO + 1 EC11 rotary encoder. No matrix, no diodes
-- each switch ties its pin to GND and uses the RP2040's internal pull-up.

Install: drop this file plus the `kmk/` library folder onto the CIRCUITPY drive
(see firmware/README.md for the full flashing steps).
"""
import board
from kmk.kmk_keyboard import KMKKeyboard
from kmk.keys import KC
from kmk.scanners.keypad import KeysScanner
from kmk.modules.encoder import EncoderHandler

keyboard = KMKKeyboard()

# --- Switches -------------------------------------------------------------
# Each switch connects its pin to GND; pressed = LOW (internal pull-up).
# Pin order here == key order in the keymap below:
# 0 = SW1 front-left D0 3 = SW4 rear-left D3
# 1 = SW2 front-center D1 4 = SW5 rear-center D6
# 2 = SW3 front-right D2 5 = SW6 rear-right D7
keyboard.matrix = KeysScanner(
pins=[board.D0, board.D1, board.D2, board.D3, board.D6, board.D7],
value_when_pressed=False, # pull-up wiring: a press pulls the pin LOW
)

# --- Rotary encoder (EC11) ------------------------------------------------
encoder = EncoderHandler()
keyboard.modules.append(encoder)
# (pin_a, pin_b, pin_button) -> A=D8, B=D9, push-switch=D10
encoder.pins = ((board.D8, board.D9, board.D10),)

# --- Keymap ---------------------------------------------------------------
# Edit any KC.* below to taste. Quick reference:
# plain keys : KC.A, KC.F13, KC.ENTER, KC.SPACE, KC.ESC
# combos : KC.LCTL(KC.C) -> Ctrl+C | KC.LGUI(KC.L) -> Win/Cmd+L
# media : KC.VOLU, KC.VOLD, KC.MUTE, KC.MPLY, KC.MNXT, KC.MPRV
keyboard.keymap = [
[
KC.LCTL(KC.C), KC.LCTL(KC.V), KC.LCTL(KC.X), # SW1 Copy SW2 Paste SW3 Cut
KC.LCTL(KC.Z), KC.LCTL(KC.Y), KC.LCTL(KC.S), # SW4 Undo SW5 Redo SW6 Save
],
]

# Encoder: (turn left, turn right, press)
encoder.map = [
((KC.VOLD, KC.VOLU, KC.MUTE),),
]

if __name__ == "__main__":
keyboard.go()
Binary file added hackpads/Hexpad-macropad/PCB/hexpad-gerbers.zip
Binary file not shown.
Loading