Fix button-to-MIDI latency: remove blocking serial, reduce debounce, faster loop

Latency sources fixed:
- debounce 50ms -> 5ms (switch_stub.cpp:15)
- Removed [MIDI OUT] Serial.printf from send_cc() (midi_transport.cpp:93-98)
- Removed [APP] Switch pressed/released prints from update() (app_task.cpp:39,43)
- Removed [APP] Switch -> CC print from process_switch_event() (app_task.cpp:140-143)
- loop() delay 10ms -> 1ms (main.cpp:390)

Serial output at 115200 baud was taking 2-5ms per printf call
in the critical button-to-MIDI path, adding 7-15ms+ total latency
per button press. All removed from hot path.
This commit is contained in:
ash
2026-07-02 06:22:23 +00:00
parent 0d22769cf6
commit c44bfb033b
4 changed files with 2 additions and 9 deletions
-6
View File
@@ -36,11 +36,9 @@ void AppTask::update() {
bool is_pressed = switch_driver->is_pressed(i);
if (is_pressed && !last_switch_state[i]) {
Serial.printf("[APP] Switch %d pressed\n", i);
process_switch_event(i, true);
last_switch_state[i] = true;
} else if (!is_pressed && last_switch_state[i]) {
Serial.printf("[APP] Switch %d released\n", i);
process_switch_event(i, false);
last_switch_state[i] = false;
}
@@ -136,10 +134,6 @@ void AppTask::process_switch_event(uint8_t switch_id, bool pressed) {
if (pressed) {
midi_transport->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");
break;
}
}