cs-midi-docs/docs/_index.md

90 lines
2.9 KiB
Markdown

# cs-midi
A standalone extraction of [tttapa/Control-Surface](https://github.com/tttapa/Control-Surface) (GPL-3.0) for embedded platforms.
cs-midi provides the full Control Surface MIDI element system — output elements, input elements, banks, selectors, MIDI routing, and the declarative `Control_Surface` singleton.
Supported platforms:
| Platform | Transport | Status |
|----------|-----------|--------|
| **RP2xxx** (pico-sdk) | BLE, USB, Serial, AppleMIDI | Stable |
| **ESP32-S3** | BLE, USB, Serial | Planned |
| **ESP32-C3** | BLE, Serial | Planned |
Use the **Platform** dropdown in the sidebar to view examples for your target device.
### RP2xxx Radio Module Note
The RP2xxx BLE transport uses BTstack with the CYW43 radio (Infineon RM2 module). While other CYW43-based radio modules may work, **only the RM2 has been tested** and has its driver fully implemented.
A pico-sdk board file for the Waveshare RP2350B Plus W (RM2-equipped) is provided at `boards/waveshare_rp2350b_plus_w.h`. To use it, set `PICO_BOARD_HEADER_DIRS` in your CMake config:
```cmake pico
set(PICO_BOARD waveshare_rp2350b_plus_w)
set(PICO_BOARD_HEADER_DIRS ${CMAKE_SOURCE_DIR}/lib/cs-midi/boards)
```
## Getting Started
```cpp pico
#include "pico/stdlib.h"
#include <cs_midi.h>
using namespace cs;
BluetoothMIDI_Interface midi;
NoteButton button {5, {MIDI_Notes::C[4], Channel_1}};
int main() {
stdio_init_all();
Control_Surface.begin();
while (true) {
Control_Surface.loop();
sleep_ms(1);
}
}
```
## Build
cs-midi is a static library meant to be included in a pico-sdk project:
```cmake pico
add_subdirectory(lib/cs-midi)
target_link_libraries(your_target cs_midi)
```
CMake options (set before `add_subdirectory()`):
| Option | Default | Description |
|--------|---------|-------------|
| `CS_MIDI_BLE` | ON | BLE MIDI via BTstack |
| `CS_MIDI_USB` | OFF | USB MIDI via TinyUSB |
| `CS_MIDI_SERIAL` | OFF | Serial MIDI over UART |
| `CS_MIDI_APPLEMIDI` | OFF | AppleMIDI (RTP-MIDI over WiFi) |
| `CS_MIDI_HID_KEYBOARD` | OFF | HID keyboard + Battery Service for BLE auto-reconnect |
USB MIDI requires `tusb_config.h` and `usb_descriptors.c` in your project — see `templates/` for reference files.
To compile-verify all examples standalone:
```sh
cd lib/cs-midi && make tests
```
## Differences from Control Surface
- `#include <cs_midi.h>` replaces `#include <Control_Surface.h>`
- Standard `main()` replaces Arduino `setup()`/`loop()`
- All types live in the `cs::` namespace
- No `MCU::` namespace yet — use raw CC numbers or `MIDI_CC::` constants
- Direct MIDI sending and callbacks available on all interface objects
- `MIDI_Callbacks` and `FineGrainedMIDI_Callbacks<T>` for incoming message handling
## Credits
Original library: [Control Surface](https://github.com/tttapa/Control-Surface) by **Pieter P (tttapa)** (GPL-3.0).
pico-sdk port: [pszsh](https://else-if.org).