PM_K-1 CircuitPython: add boot.py to guarantee the USB-MIDI port appears
If the device isn't seen as a MIDI input (USB endpoint pressure from drive+serial+HID+MIDI), boot.py disables the unused HID interface and enables usb_midi — copy it on and power-cycle. Bundled into pm_k1_circuitpy.zip; documented in the README. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
186b51ae23
commit
b5584454b3
3 changed files with 18 additions and 3 deletions
2
build.sh
2
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")
|
print("copied pico-main.py")
|
||||||
import zipfile # PM_K-1 CircuitPython drive bundle (download → unzip onto CIRCUITPY)
|
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:
|
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("pico-cp/" + f, f)
|
||||||
z.write("dist/editor.html", "editor.html") # offline copy of the editor, on the drive
|
z.write("dist/editor.html", "editor.html") # offline copy of the editor, on the drive
|
||||||
print("zipped pm_k1_circuitpy.zip")
|
print("zipped pm_k1_circuitpy.zip")
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,13 @@ same program‑string language as <https://metronome.varasys.io>.
|
||||||
The board also shows up as a **USB-MIDI** device and sends a note on every click (a GM drum note per
|
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**,
|
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
|
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
|
groove through its full synth, out your computer's speakers, locked to the device's clock. The button
|
||||||
`MUTE_BUZZER = True` in `code.py` if you'd rather silence the on-board buzzer while doing this.
|
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)
|
## Controls (same as the MicroPython build)
|
||||||
|
|
||||||
|
|
|
||||||
10
pico-cp/boot.py
Normal file
10
pico-cp/boot.py
Normal file
|
|
@ -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()
|
||||||
Loading…
Reference in a new issue