metronome/pico-cp
Me Here c499910df4 PM_K-1 CircuitPython: add the lanes/pads view
Replace the single beat-dot row with a full pad grid: each lane is a row of step
pads coloured by dynamics (mute/normal/accent/ghost), with the playhead lit as it
plays (per-lane, so polymeter shows). Header (title/BPM/RUN/item) is compacted above
it; transport stays below. Pads are vectorio rects sharing one 8-colour palette and
recolour in place via color_index (cheap, tear-free); the grid only rebuilds on track
change. Caps at MAXLANES=5 rows (extra lanes still play). Verified by rendering the whole
displayio scene graph headless (layout + playhead lighting correct).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 21:56:27 -05:00
..
__pycache__ PM_K-1 CircuitPython: add the lanes/pads view 2026-05-28 21:56:27 -05:00
code.py PM_K-1 CircuitPython: add the lanes/pads view 2026-05-28 21:56:27 -05:00
font_l.bin PM_K-1 CircuitPython: fix MemoryError + red/blue swap (from on-board test) 2026-05-28 21:30:03 -05:00
font_m.bin PM_K-1 CircuitPython: fix MemoryError + red/blue swap (from on-board test) 2026-05-28 21:30:03 -05:00
programs.json Phase 1: CircuitPython firmware (USB-drive edition) for the Kit 2026-05-28 21:10:34 -05:00
README.md PM_K-1 CircuitPython: self-contained RGB LED + fix screen tearing 2026-05-28 21:43:48 -05:00

PM_K1 "Kit" — CircuitPython edition (USB drive + editor)

The CircuitPython firmware for the 52Pi EP0172 Pico kit. Unlike the MicroPython version (../pico/main.py), this makes the Pico mount as a USB drive (CIRCUITPY) that carries the firmware and your tracks — so you can edit on the web and reprogram it without Thonny. It runs the same programstring language as https://metronome.varasys.io.

Status: experimental, phase 1. This drives the screen/touch/joystick/buzzer and reads your grooves from programs.json. The editor's oneclick "Save to device" and USBMIDI audiotocomputer are landing in later phases. The simpler MicroPython firmware (../pico/main.py) remains the rocksolid fallback — and the Pico can't be bricked (BOOTSEL → drag a MicroPython .uf2 back).

Install

  1. Flash CircuitPython: hold BOOTSEL, plug in, and drop the CircuitPython .uf2 for your board onto the RPIRP2 drive (https://circuitpython.org/board/raspberry_pi_pico/ — or the Pico 2 / W build). It reboots and a CIRCUITPY drive appears.
  2. Copy everything from the bundle onto CIRCUITPY (draganddrop — it's a normal drive now):
    • code.py (this firmware — runs on boot)
    • programs.json (your grooves)
    • font_m.bin, font_l.bin (the antialiased fonts — kept as files to save RAM)
  3. It starts immediately. Editing programs.json (or resaving it from the editor) makes CircuitPython autoreload with the new tracks.

Controls (same as the MicroPython build)

  • Touch: onscreen ◀◀ / ▶ / ▶▶ (prev · play/stop · next) and / TAP / +.
  • Joystick: up/down = tempo, left/right = previous/next groove.
  • Button A (GP15) play/stop · Button B (GP14) tap tempo.
  • RGB LED flashes each beat; buzzer clicks (accent/normal/ghost).

programs.json

{ "title": "PolyMeter",
  "programs": [ { "name": "Four on the floor", "prog": "t120;kick:4;snare:4=.x.x;hatClosed:4/2" } ] }

Each prog is a program string from the web editor. Add/replace entries and save — the device reloads.

Calibration (flip flags at the top of code.py)

  • Red/blue swapped: flip MADCTL between 0x48 (default) and 0x40.
  • Colours look negative: toggle INVERT_COLORS.
  • Taps land wrong: set TOUCH_DEBUG = True, watch the serial output, then set TOUCH_SWAP_XY / TOUCH_INVERT_X / TOUCH_INVERT_Y.
  • Joystick reversed: toggle JOY_INVERT_X / JOY_INVERT_Y.
  • Screen blank / garbled: the panel lot may differ; drop SPI_BAUD, and if it's a 240×320 ILI9341 instead of the 320×480 ST7796, the init/size need changing (this targets the 320×480 you have).
  • RGB LED is driven by the core neopixel_write module — no library to install. If it stays dark, your CircuitPython build is unusually missing that module (everything else still works).

If code.py ever errors, CircuitPython prints the traceback on the screen and over USB serial — copy that to me and I'll fix it.

The fonts are the same baked antialiased blobs as the MicroPython build (see ../pico/gen_font.py).