add debug prints around button press to find crash location
This commit is contained in:
+6
-2
@@ -134,12 +134,16 @@ void AppTask::process_switch_event(uint8_t switch_id, bool pressed) {
|
||||
if (pad_mapping[i].physical_switch == switch_id) {
|
||||
uint8_t channel = pad_mapping[i].midi_channel;
|
||||
uint8_t cc_num = cc_map[i];
|
||||
// Use palette index 127 (magenta) for visible feedback
|
||||
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.println("[APP DEBUG] after usb send");
|
||||
if (ble_midi) {
|
||||
Serial.println("[APP DEBUG] about to call ble send_cc");
|
||||
ble_midi->send_cc(channel, cc_num, value);
|
||||
Serial.println("[APP DEBUG] after ble send_cc");
|
||||
}
|
||||
}
|
||||
|
||||
Serial.printf("[APP] Switch %d -> Ch%d CC%d Val%d (%s)\n",
|
||||
|
||||
@@ -111,9 +111,21 @@ void BleMidiTransport::on_midi_receive(std::function<void(const MidiEvent&)> cal
|
||||
}
|
||||
|
||||
void BleMidiTransport::send_midi_packet(const uint8_t* data, uint8_t len) {
|
||||
if (!initialized || !client_connected || !ble_char) return;
|
||||
if (!initialized) {
|
||||
Serial.println("[BLE DBG] send_midi_packet: not initialized");
|
||||
return;
|
||||
}
|
||||
if (!client_connected) {
|
||||
Serial.println("[BLE DBG] send_midi_packet: no client");
|
||||
return;
|
||||
}
|
||||
if (!ble_char) {
|
||||
Serial.println("[BLE DBG] send_midi_packet: null char");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.println("[BLE DBG] send_midi_packet: proceeding to send");
|
||||
|
||||
// BLE MIDI format: timestamp header + raw MIDI message
|
||||
uint16_t timestamp = micros() & 0x3FFF;
|
||||
uint8_t packet[16];
|
||||
uint8_t idx = 0;
|
||||
@@ -123,8 +135,11 @@ void BleMidiTransport::send_midi_packet(const uint8_t* data, uint8_t len) {
|
||||
packet[idx++] = data[i];
|
||||
}
|
||||
|
||||
Serial.println("[BLE DBG] calling setValue...");
|
||||
ble_char->setValue(packet, idx);
|
||||
Serial.println("[BLE DBG] calling notify...");
|
||||
ble_char->notify();
|
||||
Serial.println("[BLE DBG] notify done");
|
||||
}
|
||||
|
||||
void BleMidiTransport::send_note_on(uint8_t channel, uint8_t note, uint8_t velocity) {
|
||||
@@ -140,6 +155,8 @@ void BleMidiTransport::send_note_off(uint8_t channel, uint8_t note, uint8_t velo
|
||||
}
|
||||
|
||||
void BleMidiTransport::send_cc(uint8_t channel, uint8_t cc, uint8_t value) {
|
||||
Serial.printf("[BLE DBG] send_cc entered: ch=%d cc=%d val=%d init=%d conn=%d char=%p\n",
|
||||
channel, cc, value, initialized, client_connected, ble_char);
|
||||
uint8_t packet[3] = {(uint8_t)(0xB0 | (channel - 1)), cc, value};
|
||||
send_midi_packet(packet, 3);
|
||||
Serial.printf("[BLE OUT] Ch:%d CC:%d:%d\n", channel, cc, value);
|
||||
|
||||
Reference in New Issue
Block a user