queue MIDI sends with delay(1) to avoid race; force legacy advertising
This commit is contained in:
+16
-5
@@ -49,6 +49,13 @@ void AppTask::update() {
|
||||
last_switch_state[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pending_cc) {
|
||||
pending_cc = false;
|
||||
delay(1);
|
||||
usb_midi->send_cc(pending_channel, pending_cc_num, pending_value);
|
||||
if (ble_midi) ble_midi->send_cc(pending_channel, pending_cc_num, pending_value);
|
||||
}
|
||||
}
|
||||
|
||||
void AppTask::process_midi_event(const MidiEvent& event) {
|
||||
@@ -136,14 +143,18 @@ void AppTask::process_switch_event(uint8_t switch_id, bool pressed) {
|
||||
uint8_t cc_num = cc_map[i];
|
||||
uint8_t value = pressed ? 127 : 0;
|
||||
|
||||
if (pressed) {
|
||||
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",
|
||||
switch_id, channel, cc_num, value,
|
||||
pressed ? "PRESS" : "RELEASE");
|
||||
|
||||
if (pressed) {
|
||||
// Send MIDI via a flag that loop() processes
|
||||
pending_cc = true;
|
||||
pending_channel = channel;
|
||||
pending_cc_num = cc_num;
|
||||
pending_value = value;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user