Files
nils d2bebc9e7b Initial import: Rust BLE-MIDI keypad for Pico W
Port of the C/BTstack BLE-MIDI keypad firmware to Rust (embassy + cyw43 +
trouble). 16-pad RGB keypad (APA102 SPI + I2C button expander), BLE-MIDI 1.0
GATT server (full codec: sysex, running-status, real-time), octave display
on BOOTSEL, onboard LED heartbeat, USB serial logging.

- src/keypad.rs      Pimoroni RGB Keypad driver
- src/midi_keypad.rs pad->Note On/Off + LED response state machine
- src/codec.rs       BLE-MIDI 1.0 codec (port of rppicomidi, MIT)
- src/main.rs        cyw43 BT bring-up + trouble GATT + MIDI pump
- src/octave.rs      octave digit display on BOOTSEL

GPL-3.0-or-later; codec.rs retains its MIT (rppicomidi) attribution.
2026-08-21 08:44:19 +02:00

48 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# pico-pi-midi (Rust)
BLE-MIDI keypad firmware for the Raspberry Pi Pico W (RP2040 + CYW43439), written in Rust using [embassy](https://embassy.dev), the [cyw43](https://crates.io/crates/cyw43) driver (Bluetooth), and the [TrouBLE](https://github.com/embassy-rs/trouble) BLE host.
This is the Rust port of the original C/BTstack firmware (now kept separately as `pico-pi-midi-c`). It talks BLE-MIDI 1.0 to iOS / macOS Core MIDI, turning the Pimoroni Pico RGB Keypad into a 16-pad wireless MIDI controller.
## What it does
- **16-pad keypad** (Pimoroni RGB Keypad Base): reads buttons over I²C (GPIO expander @ 0x20) and drives APA102 RGB LEDs over SPI (CS=17, SCK=18, MOSI=19).
- **BLE-MIDI 1.0** GATT server (MIDI Service `03B80E5A-…`), advertised so Core MIDI discovers it as a MIDI device. Pad presses → Note On/Off over Bluetooth; incoming Note On lights the pad.
- **Octave display**: the BOOTSEL button cycles the keypad's note offset by +12 and flashes the active octave as a digit on the 4×4 grid for 500 ms.
- **Onboard LED** heartbeat (driven via the CYW43 chip — the Pico W's LED is on the wireless chip, not an RP2040 pin).
- **USB serial logging** via `embassy-usb-logger` — connect and read with `screen /dev/cu.usbmodem* 115200` to see boot/advertising logs.
## Roadmap
This is v1: a BLE-MIDI keypad. The goal is a **flexible MIDI router** — MIDI over USB, BLE, keypad, TRS, and 4 stereo CV outputs, with channels configurable at runtime via an LCD. See the architecture notes (kept in the session memory) for the plan.
## Building
Requires Rust stable (≥1.93) and the `thumbv6m-none-eabi` target:
```sh
rustup target add thumbv6m-none-eabi
cargo build --release
```
The CYW43 firmware blobs (`cyw43-firmware/*.bin`) are committed here so no network access is needed at build time. They are redistributable under the permissive binary license in the upstream [`embassy cyw43-firmware`](https://github.com/embassy-rs/embassy/tree/main/cyw43-firmware) directory.
## Flashing
```sh
cargo build --release
elf2uf2-rs convert target/thumbv6m-none-eabi/release/rgb-keypad target/uf2/rgb-keypad.uf2
# hold BOOTSEL + plug in the Pico W, then:
picotool load target/uf2/rgb-keypad.uf2 -x
```
## License
GPL-3.0-or-later (see [`LICENSE`](LICENSE)).
`src/codec.rs` is a Rust port of the BLE-MIDI 1.0 packet codec from
[rppicomidi/pico-w-ble-midi-lib](https://github.com/rppicomidi/pico-w-ble-midi-lib),
which is MIT-licensed; that attribution is retained in the file header. MIT is
GPL-3.0-compatible, so the repository as a whole is GPL-3.0-or-later while that
file preserves its MIT provenance.