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); event_handler_hook_use(eventHandler);
loop_hook_use(loopHook); loop_hook_use(loopHook);
syncTimer = millis(); syncTimer = millis() + syncDelay;
} }
Key Key
@ -148,9 +148,9 @@ LEDControl_::loopHook (bool postClear) {
if (postClear) if (postClear)
return; return;
if (millis() - syncTimer >= syncDelay) { if (millis() > syncTimer) {
led_sync(); led_sync();
syncTimer = millis(); syncTimer = millis() + syncDelay;
} }
update(); update();
} }

Loading…
Cancel
Save