metronome/pico
Me Here eecea625d3 Add PM_K-1 "Kit" — buildable Pico touchscreen unit + MicroPython firmware
A new, first-actually-buildable form factor for the 52Pi EP-0172 "Pico Breadboard
Kit Plus" (Raspberry Pi Pico; 3.5" ST7796 320x480 cap-touch via GT911, PSP
joystick on ADC0/1, WS2812 RGB on GP12, buzzer GP13, buttons GP14/15):

  - pico/main.py — one self-contained MicroPython file: ST7796 direct-draw driver,
    GT911 touch (16-bit register addressing), WS2812 RGB (neopixel), PWM buzzer,
    ADC joystick, buttons. It parses the project's own program-string language
    (verified against the web engine's semantics) and runs a non-blocking
    ticks_us scheduler with an on-screen touch UI. CONFIG flags cover panel /
    colour / touch / joystick calibration. pico/README.md has flashing +
    calibration steps.
  - kit.html — lean widget that mirrors the firmware's on-screen UI (portrait
    320x480 canvas) plus a joystick / RGB / buzzer / A-B buttons; plays via the
    shared engine. info-kit.html — the real EP-0172 pinout, a parts list
    (~$45 incl. Pico) and the firmware to flash (downloads /pico-main.py, links
    the README + source).
  - Landing + embed page list the Kit; build.sh/deploy.sh build the two pages and
    serve pico/main.py as /pico-main.py for download.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 16:10:31 -05:00
..
__pycache__ Add PM_K-1 "Kit" — buildable Pico touchscreen unit + MicroPython firmware 2026-05-28 16:10:31 -05:00
main.py Add PM_K-1 "Kit" — buildable Pico touchscreen unit + MicroPython firmware 2026-05-28 16:10:31 -05:00
README.md Add PM_K-1 "Kit" — buildable Pico touchscreen unit + MicroPython firmware 2026-05-28 16:10:31 -05:00

PM_K1 "Kit" — VARASYS PolyMeter firmware for the Raspberry Pi Pico

MicroPython firmware that turns a Raspberry Pi Pico on the 52Pi EP0172 "Pico Breadboard Kit Plus" into a touchscreen polymeter metronome. It runs the same program strings as https://metronome.varasys.io — design a groove in the web editor, copy its program string, paste it into PROGRAMS in main.py, and it plays here.

Everything is in one file: main.py (ST7796 display driver, GT911 touch, WS2812 RGB, buzzer, joystick, the polymeter engine — no external libraries).

The board (EP0172) — fixed pinout

Component Pico pins
3.5″ ST7796 320×480 display SPI0 — SCK GP2, MOSI GP3, CS GP5, DC GP6, RST GP7
GT911 capacitive touch I2C0 — SDA GP8, SCL GP9 (addr 0x5D)
WS2812 RGB LED GP12
Buzzer GP13
Button A / Button B GP15 / GP14
PSP joystick X = ADC0/GP26, Y = ADC1/GP27

The components are wired on the board — you don't breadboard anything; just seat the Pico.

Flash it

  1. MicroPython: hold BOOTSEL, plug the Pico into USB, and copy the MicroPython UF2 onto the RPI-RP2 drive that appears:
  2. The firmware: open main.py in Thonny (or rshell/mpremote) and save it to the Pico as main.py.
    • Thonny: open the file → File ▸ Save as… ▸ Raspberry Pi Pico → name it main.py.
    • mpremote: mpremote cp main.py :main.py
  3. Reset (replug). It boots straight into the metronome.

Controls

  • Touch: onscreen << / >|| / >> (prev · play/stop · next) and / TAP / +.
  • Joystick: up/down = tempo (push far for ±5), left/right = previous/next groove.
  • Button A (GP15): play / stop. Button B (GP14): tap tempo.
  • RGB LED flashes each beat (amber = accent, cyan = normal, violet = ghost); the buzzer clicks with matching pitch.

Add your own grooves

Edit the PROGRAMS list near the top of main.py — each entry is ("Name", "program string"). Get program strings from the web editor's program box (e.g. v1;t120;kick:4;snare:4=.X.X;hat:4/2). Supported: tempo t<bpm>, lanes sound:grouping[/sub][=pattern][~][!], pattern chars X accent · x normal · g ghost · . - _ rest, grouped meters like 3+3+2, polymeter ~. (Perlane dB gain @n is parsed but ignored — the buzzer is mono.)

If something looks off — calibration

All the knobs are flags in the CONFIG block at the top of main.py:

  • Colours look negative / washed out: toggle INVERT_COLORS.
  • Red and blue swapped: set SWAP_RB = True.
  • Taps land in the wrong place: set TOUCH_DEBUG = True, reset, watch the raw coordinates over the USB serial (Thonny shell) as you tap the corners, then set TOUCH_SWAP_XY / TOUCH_INVERT_X / TOUCH_INVERT_Y to match.
  • Joystick reversed: toggle JOY_INVERT_X / JOY_INVERT_Y; widen JOY_DEADZONE if it drifts.
  • Screen stays black: the backlight is hardwired on, so this usually means the SPI init didn't take — drop SPI_BAUD to 24_000_000 and retry.
  • Garbled / wrong size image: your panel lot may be a 240×320 ILI9341 instead of the 320×480 ST7796. This firmware targets the ST7796 you have (you said 320×480); if a unit ever ships ILI9341, set WIDTH,HEIGHT = 240,320 and use an ILI9341 init sequence.

Notes

  • Audio is a single passive buzzer, so coincident lane hits play one click at the highest priority (accent > normal > ghost); the RGB + screen still show the combined activity.
  • The scheduler is nonblocking and timed off time.ticks_us(), so tempo stays steady while the screen and inputs update.

Hardware reference: 52Pi EP0172 wiki · vendor code. VARASYS — Simplifying Complexity.