Use standard timeout checker for IdleLEDs

Also, remove unnecessary `onSetup()` hook function.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/642/head
Michael Richters 6 years ago
parent f66415e34f
commit e7fd8a326a

@ -22,11 +22,11 @@ namespace kaleidoscope {
namespace plugin {
uint16_t IdleLEDs::idle_time_limit = 600; // 10 minutes
uint32_t IdleLEDs::end_time_;
uint32_t IdleLEDs::start_time_ = 0;
EventHandlerResult IdleLEDs::beforeEachCycle() {
if (!::LEDControl.paused &&
(Kaleidoscope.millisAtCycleStart() >= end_time_)) {
Kaleidoscope.hasTimeExpired(start_time_, uint32_t(idle_time_limit * 1000))) {
::LEDControl.set_all_leds_to(CRGB(0, 0, 0));
::LEDControl.syncLeds();
@ -43,7 +43,7 @@ EventHandlerResult IdleLEDs::onKeyswitchEvent(Key &mapped_key, byte row, byte co
::LEDControl.refreshAll();
}
end_time_ = Kaleidoscope.millisAtCycleStart() + (uint32_t)idle_time_limit * 1000;
start_time_ = Kaleidoscope.millisAtCycleStart();
return EventHandlerResult::OK;
}

@ -28,15 +28,11 @@ class IdleLEDs: public kaleidoscope::Plugin {
static uint16_t idle_time_limit;
EventHandlerResult onSetup() {
end_time_ = millis() + idle_time_limit * 1000;
return EventHandlerResult::OK;
}
EventHandlerResult beforeEachCycle();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state);
private:
static uint32_t end_time_;
static uint32_t start_time_;
};
}
}

Loading…
Cancel
Save