diff --git a/build.sh b/build.sh index 9b8919f..226f864 100755 --- a/build.sh +++ b/build.sh @@ -39,7 +39,7 @@ pathlib.Path("dist/pico-main.py").write_text(pathlib.Path("pico/main.py").read_t print("copied pico-main.py") import zipfile # PM_K-1 CircuitPython drive bundle (download → unzip onto CIRCUITPY) with zipfile.ZipFile("dist/pm_k1_circuitpy.zip", "w", zipfile.ZIP_DEFLATED) as z: - for f in ("code.py", "programs.json", "font_s.bin", "font_m.bin", "font_l.bin", "README.md"): + for f in ("code.py", "boot.py", "programs.json", "font_s.bin", "font_m.bin", "font_l.bin", "README.md"): z.write("pico-cp/" + f, f) z.write("dist/editor.html", "editor.html") # offline copy of the editor, on the drive print("zipped pm_k1_circuitpy.zip") diff --git a/pico-cp/README.md b/pico-cp/README.md index ffd4f56..72da209 100644 --- a/pico-cp/README.md +++ b/pico-cp/README.md @@ -28,8 +28,13 @@ same program‑string language as . The board also shows up as a **USB-MIDI** device and sends a note on every click (a GM drum note per lane, velocity by accent). Open the [editor](https://metronome.varasys.io/editor.html) in **Chrome/Edge**, click **🎹 Device audio**, grant MIDI access, then press play *on the device* — the editor voices the -groove through its full synth, out your computer's speakers, locked to the device's clock. Set -`MUTE_BUZZER = True` in `code.py` if you'd rather silence the on-board buzzer while doing this. +groove through its full synth, out your computer's speakers, locked to the device's clock. The button +shows the connected device's name and pulses green on each note; set `MUTE_BUZZER = True` in `code.py` +if you'd rather silence the on-board buzzer while doing this. + +If the editor says **no MIDI input is connected**, copy **`boot.py`** onto `CIRCUITPY` too and +**power-cycle** the Pico (`boot.py` only runs on a full reset). It frees a USB endpoint (drops the +unused HID interface) so the MIDI port is guaranteed to appear alongside the drive. ## Controls (same as the MicroPython build) diff --git a/pico-cp/boot.py b/pico-cp/boot.py new file mode 100644 index 0000000..095b8ad --- /dev/null +++ b/pico-cp/boot.py @@ -0,0 +1,10 @@ +# boot.py — runs once before USB connects (hard reset / power-cycle to apply). +# Guarantees the device shows up as a USB-MIDI port so the web editor's "Device audio" +# can hear it. We don't use HID, so disabling it frees a USB endpoint for MIDI on the +# Pico (which also exposes the CIRCUITPY drive + serial at the same time). +import usb_hid, usb_midi +try: + usb_hid.disable() +except Exception: + pass +usb_midi.enable()