From 0d22199cac975ab2ae22a5ab94dc3d20c41fe259 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 15 Aug 2017 22:47:28 +0200 Subject: [PATCH] Updated to use the new LEDMode/LEDControl API Signed-off-by: Gergely Nagy --- src/Kaleidoscope/AlphaSquare-Effect.cpp | 17 ++++------------- src/Kaleidoscope/AlphaSquare-Effect.h | 8 ++++---- src/Kaleidoscope/LED-AlphaSquare.cpp | 4 ++-- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/Kaleidoscope/AlphaSquare-Effect.cpp b/src/Kaleidoscope/AlphaSquare-Effect.cpp index c960e104..dc1bc208 100644 --- a/src/Kaleidoscope/AlphaSquare-Effect.cpp +++ b/src/Kaleidoscope/AlphaSquare-Effect.cpp @@ -23,20 +23,12 @@ namespace kaleidoscope { uint16_t AlphaSquareEffect::length = 1000; uint32_t AlphaSquareEffect::end_time_left_, AlphaSquareEffect::end_time_right_; Key AlphaSquareEffect::last_key_left_, AlphaSquareEffect::last_key_right_; -uint8_t AlphaSquareEffect::us_; -AlphaSquareEffect::AlphaSquareEffect(void) { -} - -void -AlphaSquareEffect::begin(void) { +void AlphaSquareEffect::setup(void) { Kaleidoscope.useEventHandlerHook(eventHandlerHook); - Kaleidoscope.use(&LEDControl); - us_ = LEDControl.mode_add(this); } -void -AlphaSquareEffect::update(void) { +void AlphaSquareEffect::update(void) { if (end_time_left_ && millis() > end_time_left_) { ::AlphaSquare.clear(last_key_left_); end_time_left_ = 0; @@ -47,9 +39,8 @@ AlphaSquareEffect::update(void) { } } -Key -AlphaSquareEffect::eventHandlerHook(Key key, byte row, byte col, uint8_t key_state) { - if (LEDControl.get_mode() != us_) +Key AlphaSquareEffect::eventHandlerHook(Key key, byte row, byte col, uint8_t key_state) { + if (::LEDControl.get_mode() != &::AlphaSquareEffect) return key; if (key_state & INJECTED) diff --git a/src/Kaleidoscope/AlphaSquare-Effect.h b/src/Kaleidoscope/AlphaSquare-Effect.h index 5b32ce12..0f60a452 100644 --- a/src/Kaleidoscope/AlphaSquare-Effect.h +++ b/src/Kaleidoscope/AlphaSquare-Effect.h @@ -24,16 +24,16 @@ namespace kaleidoscope { class AlphaSquareEffect : public LEDMode { public: - AlphaSquareEffect(void); + AlphaSquareEffect(void) {} - void begin(void) final; + static uint16_t length; + protected: + void setup(void) final; void update(void) final; - static uint16_t length; private: static uint32_t end_time_left_, end_time_right_; static Key last_key_left_, last_key_right_; - static uint8_t us_; static Key eventHandlerHook(Key key, uint8_t row, uint8_t col, uint8_t key_state); }; diff --git a/src/Kaleidoscope/LED-AlphaSquare.cpp b/src/Kaleidoscope/LED-AlphaSquare.cpp index 5327af83..9a7184f0 100644 --- a/src/Kaleidoscope/LED-AlphaSquare.cpp +++ b/src/Kaleidoscope/LED-AlphaSquare.cpp @@ -90,11 +90,11 @@ void AlphaSquare::display(uint16_t symbol, uint8_t row, uint8_t col, cRGB key_co if (!pixel) continue; - LEDControl.setCrgbAt(row + r, col + c, key_color); + ::LEDControl.setCrgbAt(row + r, col + c, key_color); } } - LEDControl.syncLeds(); + ::LEDControl.syncLeds(); } void AlphaSquare::display(uint16_t symbol, uint8_t row, uint8_t col) {