From 4342080621573bcc4111005942be2043e0099ced Mon Sep 17 00:00:00 2001 From: David Glasser Date: Wed, 18 Oct 2017 09:29:14 -0700 Subject: [PATCH] Turn off light when done Fixes #2. --- src/Kaleidoscope-LEDEffect-BootGreeting.cpp | 31 ++++++++++++++------- src/Kaleidoscope-LEDEffect-BootGreeting.h | 2 ++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/Kaleidoscope-LEDEffect-BootGreeting.cpp b/src/Kaleidoscope-LEDEffect-BootGreeting.cpp index 9475e9d4..87c3749b 100644 --- a/src/Kaleidoscope-LEDEffect-BootGreeting.cpp +++ b/src/Kaleidoscope-LEDEffect-BootGreeting.cpp @@ -22,9 +22,27 @@ namespace kaleidoscope { bool BootGreetingEffect::done_; +byte BootGreetingEffect::row_; +byte BootGreetingEffect::col_; void BootGreetingEffect::begin(void) { Kaleidoscope.useLoopHook(loopHook); + + // Find the LED key. + for (uint8_t r = 0; r < ROWS; r++) { + for (uint8_t c = 0; c < COLS; c++) { + Key k = Layer.lookupOnActiveLayer(r, c); + + if (k == Key_LEDEffectNext) { + row_ = r; + col_ = c; + return; + } + } + } + + // We didn't find the LED key. Let's just pretend we're "done". + done_ = true; } void BootGreetingEffect::loopHook(const bool post_clear) { @@ -33,19 +51,12 @@ void BootGreetingEffect::loopHook(const bool post_clear) { if (millis() > 9200) { done_ = true; + ::LEDControl.refreshAt(row_, col_); return; } - for (uint8_t r = 0; r < ROWS; r++) { - for (uint8_t c = 0; c < COLS; c++) { - Key k = Layer.lookupOnActiveLayer(r, c); - - if (k == Key_LEDEffectNext) { - cRGB color = breath_compute(); - ::LEDControl.setCrgbAt(r, c, color); - } - } - } + cRGB color = breath_compute(); + ::LEDControl.setCrgbAt(row_, col_, color); } } diff --git a/src/Kaleidoscope-LEDEffect-BootGreeting.h b/src/Kaleidoscope-LEDEffect-BootGreeting.h index ace51843..acd48fdb 100644 --- a/src/Kaleidoscope-LEDEffect-BootGreeting.h +++ b/src/Kaleidoscope-LEDEffect-BootGreeting.h @@ -30,6 +30,8 @@ class BootGreetingEffect : public KaleidoscopePlugin { private: static void loopHook(const bool post_clear); static bool done_; + static byte row_; + static byte col_; }; }