Add BLE MIDI transport (feature_bluetooth)
This commit is contained in:
+12
-7
@@ -1,8 +1,8 @@
|
||||
#include "app_task.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
AppTask::AppTask(LedStub* led, SwitchStub* sw, UsbMidiTransport* midi)
|
||||
: led_driver(led), switch_driver(sw), midi_transport(midi) {
|
||||
AppTask::AppTask(LedStub* led, SwitchStub* sw, UsbMidiTransport* usb_midi, BleMidiTransport* ble_midi)
|
||||
: led_driver(led), switch_driver(sw), usb_midi(usb_midi), ble_midi(ble_midi) {
|
||||
|
||||
// Launchpad X standard: bottom row = notes 36-45 (C2 to A2) on channel 1
|
||||
const uint8_t launchpad_notes[10] = {36, 37, 38, 39, 40, 41, 42, 43, 44, 45};
|
||||
@@ -20,11 +20,15 @@ AppTask::AppTask(LedStub* led, SwitchStub* sw, UsbMidiTransport* midi)
|
||||
|
||||
void AppTask::begin() {
|
||||
Serial.println("[APP] Registering MIDI callbacks...");
|
||||
|
||||
midi_transport->on_midi_receive([this](const MidiEvent& event) {
|
||||
|
||||
auto handler = [this](const MidiEvent& event) {
|
||||
process_midi_event(event);
|
||||
});
|
||||
|
||||
};
|
||||
usb_midi->on_midi_receive(handler);
|
||||
if (ble_midi) {
|
||||
ble_midi->on_midi_receive(handler);
|
||||
}
|
||||
|
||||
Serial.println("[APP] Controller ready - CC mode");
|
||||
for (uint8_t i = 0; i < NUM_PADS; i++) {
|
||||
Serial.printf("[APP] Pad %d -> CC%d -> LED%d\n", i + 1, cc_map[i], i);
|
||||
@@ -134,7 +138,8 @@ void AppTask::process_switch_event(uint8_t switch_id, bool pressed) {
|
||||
uint8_t value = pressed ? 127 : 0;
|
||||
|
||||
if (pressed) {
|
||||
midi_transport->send_cc(channel, cc_num, value);
|
||||
usb_midi->send_cc(channel, cc_num, value);
|
||||
if (ble_midi) ble_midi->send_cc(channel, cc_num, value);
|
||||
}
|
||||
|
||||
Serial.printf("[APP] Switch %d -> Ch%d CC%d Val%d (%s)\n",
|
||||
|
||||
Reference in New Issue
Block a user