Merge pull request #26 from Dygmalab/master

fixed LED sync overflow bug
pull/365/head
Jesse Vincent 6 years ago committed by GitHub
commit 03801306cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;
}

Loading…
Cancel
Save