Improved timer checking code

Instead of doing a substraction and a compare in the if check, whenever we reset
the timer, add `syncDelay`, and compare against the timer only. Should result in
marginally better performing code.

Thanks @obra for the suggestion!

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago
parent 559eab96ae
commit 09afa0ec72

@ -129,7 +129,7 @@ LEDControl_::begin (void) {
event_handler_hook_use(eventHandler);
loop_hook_use(loopHook);
syncTimer = millis();
syncTimer = millis() + syncDelay;
}
Key
@ -148,9 +148,9 @@ LEDControl_::loopHook (bool postClear) {
if (postClear)
return;
if (millis() - syncTimer >= syncDelay) {
if (millis() > syncTimer) {
led_sync();
syncTimer = millis();
syncTimer = millis() + syncDelay;
}
update();
}

Loading…
Cancel
Save