PM_K-1 CircuitPython: fix MemoryError + red/blue swap (from on-board test)
On hardware the app rendered, beeped and took input, then died with MemoryError at the text Bitmap alloc — the two ~37KB base64 font strings stayed pinned in RAM. Move the fonts to small binary files read at boot (font_m.bin / font_l.bin), drop the base64 + binascii, and gc.collect() before each text bitmap. code.py 56KB -> 20KB and RAM use drops ~37KB+. Also: cyan rendered as yellow (R/B swapped) -> MADCTL 0x40 -> 0x48. Bundle + README updated to include the font blobs. (LED still needs the neopixel lib.) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2c40baec58
commit
111da49b5a
6 changed files with 15 additions and 14 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", "README.md"):
|
for f in ("code.py", "programs.json", "font_m.bin", "font_l.bin", "README.md"):
|
||||||
z.write("pico-cp/" + f, f)
|
z.write("pico-cp/" + f, f)
|
||||||
print("zipped pm_k1_circuitpy.zip")
|
print("zipped pm_k1_circuitpy.zip")
|
||||||
PY
|
PY
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,10 @@ same program‑string language as <https://metronome.varasys.io>.
|
||||||
1. **Flash CircuitPython:** hold **BOOTSEL**, plug in, and drop the CircuitPython `.uf2` for your board
|
1. **Flash CircuitPython:** hold **BOOTSEL**, plug in, and drop the CircuitPython `.uf2` for your board
|
||||||
onto the `RPI‑RP2` drive (<https://circuitpython.org/board/raspberry_pi_pico/> — or the Pico 2 / W
|
onto the `RPI‑RP2` drive (<https://circuitpython.org/board/raspberry_pi_pico/> — or the Pico 2 / W
|
||||||
build). It reboots and a **`CIRCUITPY`** drive appears.
|
build). It reboots and a **`CIRCUITPY`** drive appears.
|
||||||
2. **Copy the files** onto `CIRCUITPY` (drag‑and‑drop — it's a normal drive now):
|
2. **Copy everything from the bundle** onto `CIRCUITPY` (drag‑and‑drop — it's a normal drive now):
|
||||||
- `code.py` (this firmware — runs on boot)
|
- `code.py` (this firmware — runs on boot)
|
||||||
- `programs.json` (your grooves)
|
- `programs.json` (your grooves)
|
||||||
|
- `font_m.bin`, `font_l.bin` (the anti‑aliased fonts — kept as files to save RAM)
|
||||||
3. It starts immediately. Editing `programs.json` (or re‑saving it from the editor) makes CircuitPython
|
3. It starts immediately. Editing `programs.json` (or re‑saving it from the editor) makes CircuitPython
|
||||||
**auto‑reload** with the new tracks.
|
**auto‑reload** with the new tracks.
|
||||||
|
|
||||||
|
|
@ -39,7 +40,7 @@ Each `prog` is a program string from the web editor. Add/replace entries and sav
|
||||||
|
|
||||||
## Calibration (flip flags at the top of `code.py`)
|
## Calibration (flip flags at the top of `code.py`)
|
||||||
|
|
||||||
- **Red/blue swapped:** change `MADCTL = 0x40` to `0x48`.
|
- **Red/blue swapped:** flip `MADCTL` between `0x48` (default) and `0x40`.
|
||||||
- **Colours look negative:** toggle `INVERT_COLORS`.
|
- **Colours look negative:** toggle `INVERT_COLORS`.
|
||||||
- **Taps land wrong:** set `TOUCH_DEBUG = True`, watch the serial output, then set
|
- **Taps land wrong:** set `TOUCH_DEBUG = True`, watch the serial output, then set
|
||||||
`TOUCH_SWAP_XY` / `TOUCH_INVERT_X` / `TOUCH_INVERT_Y`.
|
`TOUCH_SWAP_XY` / `TOUCH_INVERT_X` / `TOUCH_INVERT_Y`.
|
||||||
|
|
|
||||||
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
pico-cp/font_l.bin
Normal file
BIN
pico-cp/font_l.bin
Normal file
Binary file not shown.
BIN
pico-cp/font_m.bin
Normal file
BIN
pico-cp/font_m.bin
Normal file
Binary file not shown.
Loading…
Reference in a new issue