From 3226986709242dea1fa81337017ab10c688fe6cc Mon Sep 17 00:00:00 2001 From: Ashley Strahle Date: Fri, 3 Jul 2026 08:13:08 +0000 Subject: [PATCH] Capture tick 0 (last_beat=UINT32_MAX) so downbeat is not skipped --- src/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8d72602..0a62824 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,7 +29,8 @@ void midi_task(void* parameter) { Serial.println("[TASK] MIDI task started on core 0"); // Beat timing fixes for precise beat alignment - sync to real MIDI time, not hardcoded tempo - uint32_t last_beat = 0; + // UINT32_MAX ensures tick 0 (first 0xF8 after START) triggers a flash + uint32_t last_beat = UINT32_MAX; uint32_t flash_start = 0; while (true) { @@ -44,8 +45,8 @@ void midi_task(void* parameter) { if (current_beat != last_beat) { last_beat = current_beat; flash_start = now + flash_latency; - // Beat 1 (every 4th) = RED, others = WHITE - if (current_beat % 4 == 1) { + // Beat 1 = red on current_beat % 4 == 0, others = white + if (current_beat % 4 == 0) { mux.set_led_color(6, 255, 0, 0); } else { mux.set_led_color(6, 255, 255, 255); @@ -54,7 +55,7 @@ void midi_task(void* parameter) { if (flash_start > 0 && now >= flash_start) { mux.show(); - uint32_t hold = (last_beat % 4 == 1) ? 100 : 50; + uint32_t hold = (last_beat % 4 == 0) ? 100 : 50; uint32_t elapsed = now - flash_start; if (elapsed >= hold) { mux.set_led_color(6, 20, 20, 20);