Use standard timeout checker for LED-BootGreeting

Alos, don't bother to set `start_time` in `onSetup()`; it's
unnecessary. Instead, call `findLed()` there.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/642/head
Michael Richters 5 years ago
parent 6a830f01af
commit 85b47caa73

@ -60,6 +60,11 @@ void BootGreetingEffect::findLed(void) {
done_ = true; done_ = true;
} }
EventHandlerResult BootGreetingEffect::onSetup() {
findLed();
return EventHandlerResult::OK;
}
EventHandlerResult BootGreetingEffect::afterEachCycle() { EventHandlerResult BootGreetingEffect::afterEachCycle() {
if (!Kaleidoscope.has_leds) if (!Kaleidoscope.has_leds)
return EventHandlerResult::OK; return EventHandlerResult::OK;
@ -69,17 +74,8 @@ EventHandlerResult BootGreetingEffect::afterEachCycle() {
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
//If the start time isn't set, set the start time and
//find the LEDs.
if (start_time == 0) {
start_time = millis();
findLed();
//the first time, don't do anything.
return EventHandlerResult::OK;
}
//Only run for 'timeout' milliseconds //Only run for 'timeout' milliseconds
if ((millis() - start_time) > timeout) { if (Kaleidoscope.hasTimeExpired(start_time, timeout)) {
done_ = true; done_ = true;
::LEDControl.refreshAt(row_, col_); ::LEDControl.refreshAt(row_, col_);
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -32,6 +32,7 @@ class BootGreetingEffect : public kaleidoscope::Plugin {
static uint8_t hue; static uint8_t hue;
static uint16_t timeout; static uint16_t timeout;
EventHandlerResult onSetup();
EventHandlerResult afterEachCycle(); EventHandlerResult afterEachCycle();
private: private:

Loading…
Cancel
Save