diff --git a/src/Kaleidoscope-LEDControl.cpp b/src/Kaleidoscope-LEDControl.cpp index 4ae30a6d..80266a77 100644 --- a/src/Kaleidoscope-LEDControl.cpp +++ b/src/Kaleidoscope-LEDControl.cpp @@ -151,8 +151,12 @@ kaleidoscope::EventHandlerResult LEDControl::beforeReportingState(void) { if (paused) return kaleidoscope::EventHandlerResult::OK; - uint16_t current_time = millis(); - if ((current_time - syncTimer) > syncDelay) { + // unsigned subtraction means that as syncTimer rolls over + // the same interval is kept + uint16_t elapsed = Kaleidoscope.millisAtCycleStart() - syncTimer; + // on some platforms, the subtraction in the comparison results in a signed + // operation, resulting in syncLeds() no longer getting called. + if (elapsed > syncDelay) { syncLeds(); syncTimer += syncDelay; }