Adds the per-track end-action model designed in docs/track-format.md §3, end to end across both engines, both firmwares, and the editors. Grammar (parsed + serialized by engine.js and both app.py): rep=<n> cycles before the end-action fires (default 1) end=stop stop after rep cycles end=next advance one track (sugar for end=+1) end=<±N> relative goto after rep cycles (e.g. end=-2 = D.S.) (absent) loop forever — the metronome default Firmware runtime (pico-cp + pico-explorer): _on_new_bar now consults a per-track _end_plan() and fires stop / gapless-advance / relative-goto at the right bar. A cycle = b<bars>, else one master bar; fire bar = rep * cycle. Explicit end= governs; with no end, the global Continue toggle stays a default (=end=next, still needs b<bars>) so existing set-lists and the CONT UI are unchanged. _prepare_next takes a target index; the seam machinery, _do_advance and live-sync all carry rep/end. Editors (editor.html + editor-beta.html): state.rep/state.end thread through applySetup / currentSetup / currentPatch so load -> edit -> save preserves the flow; authoring is via the program-string field (no graphical control yet). Tests: the 3 playback-flow vectors now pass on both engines (39 pass / 3 known). Runtime decision logic (_end_plan / _goto_target) unit-tested for stop, rep, relative goto clamp/wrap, and legacy-Continue precedence. Codec round-trip verified idempotent. Both firmwares compile + mpy-cross clean. Also: untrack stale __pycache__/*.pyc build artifacts and gitignore them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| diagram.json | ||
| main.py | ||
| README.md | ||
| ssd1306.py | ||
Wokwi simulation — PM‑µ Micro (Raspberry Pi Pico)
A runnable Wokwi simulation of the PM‑µ Micro metronome on a Raspberry Pi Pico (RP2040), in MicroPython. It's a functional stand‑in — Wokwi has no 14‑segment display or analog audio path, so we approximate:
| Real device | Simulated with |
|---|---|
| Clickable thumb‑roller | KY‑040 rotary encoder (rotate / press / hold+rotate) |
| Amber 14‑segment display | SSD1306 OLED (shows BPM and track names) |
| Analog click + speaker | Piezo buzzer (accent beat = higher, longer beep) |
Controls
- Rotate the encoder → tempo (BPM)
- Press (the encoder's button) → start / stop
- Hold the button + rotate → switch track (release to load it)
Run it (you do this part — I can't operate your Wokwi account)
I can't log into wokwi.com or create the project on the site for you. Use these files:
- Open https://wokwi.com/pi-pico — it starts a new Pi Pico MicroPython project.
- Click the
diagram.jsontab and replace its contents with this folder'sdiagram.json. - Replace
main.pywith this folder'smain.py. - Add a new file named
ssd1306.py(the + next to the file tabs) and paste this folder'sssd1306.py. - Press ▶ (play). Rotate / click the encoder; you'll hear the click and see the OLED update.
If you use the Wokwi VS Code extension instead, keep these three files together and add a
diagram.jsonreference as usual.
Pin map (Pico GPIO)
| Function | Pin |
|---|---|
| OLED SDA / SCL (I²C0) | GP0 / GP1 |
| Encoder CLK / DT / SW | GP2 / GP3 / GP4 |
| Buzzer | GP5 |
| OLED + encoder power | 3V3 / GND |
The real firmware ("PORTS TO FIRMWARE" in the web app) drives a 14‑segment display over I²C and injects the click into the analog signal path; this sim keeps the same control model and beat scheduling so the feel matches.