Add diagnostic prints to verify MIDI Clock (0xF8) reception
This commit is contained in:
+12
-4
@@ -32,14 +32,22 @@ void midi_task(void* parameter) {
|
||||
midi_transport.update();
|
||||
exp_pedal.update(midi_transport);
|
||||
|
||||
uint32_t beat = midi_tick_count / 24;
|
||||
if (beat != last_beat) {
|
||||
last_beat = beat;
|
||||
flash_start = millis();
|
||||
uint32_t tick = midi_tick_count;
|
||||
uint32_t now = millis();
|
||||
|
||||
if (tick / 24 != last_beat) {
|
||||
last_beat = tick / 24;
|
||||
flash_start = now;
|
||||
mux.set_led_color(6, 255, 255, 255);
|
||||
mux.show();
|
||||
}
|
||||
|
||||
static uint32_t last_diag = 0;
|
||||
if (now - last_diag > 2000) {
|
||||
last_diag = now;
|
||||
Serial.printf("[CLK] ticks=%lu beat=%lu\n", (unsigned long)tick, (unsigned long)last_beat);
|
||||
}
|
||||
|
||||
if (flash_start > 0) {
|
||||
uint32_t elapsed = millis() - flash_start;
|
||||
if (elapsed >= 80) {
|
||||
|
||||
@@ -50,12 +50,20 @@ void UsbMidiTransport::update() {
|
||||
TinyUSBDevice.mounted() ? "YES" : "NO");
|
||||
}
|
||||
|
||||
static uint8_t clock_diag_count = 0;
|
||||
while (usb_midi.available()) {
|
||||
uint8_t packet[4];
|
||||
if (usb_midi.readPacket(packet)) {
|
||||
uint8_t cin = packet[0] & 0x0F;
|
||||
if (cin == 0x0F) {
|
||||
if (packet[1] == 0xF8) midi_tick_count++;
|
||||
if (packet[1] == 0xF8) {
|
||||
midi_tick_count++;
|
||||
if (clock_diag_count < 5) {
|
||||
Serial.printf("[CLK] pkt=%02X %02X %02X %02X cin=%X\n",
|
||||
packet[0], packet[1], packet[2], packet[3], cin);
|
||||
clock_diag_count++;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user