From 8bb7a5b1e41849c4853e5a5926d5e0b2d91b64a1 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 15 Aug 2017 22:51:17 +0200 Subject: [PATCH] Updated to use the new LEDMode/LEDControl API Signed-off-by: Gergely Nagy --- src/Kaleidoscope/LED-Stalker.cpp | 14 +++++--------- src/Kaleidoscope/LED-Stalker.h | 11 ++++++----- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Kaleidoscope/LED-Stalker.cpp b/src/Kaleidoscope/LED-Stalker.cpp index 691f47fe..055b7978 100644 --- a/src/Kaleidoscope/LED-Stalker.cpp +++ b/src/Kaleidoscope/LED-Stalker.cpp @@ -26,15 +26,11 @@ StalkerEffect::ColorComputer *StalkerEffect::variant; uint16_t StalkerEffect::step_length = 50; uint32_t StalkerEffect::step_end_time_; -StalkerEffect::StalkerEffect(void) { +void StalkerEffect::setup(void) { + Kaleidoscope.useEventHandlerHook(eventHandlerHook); } -void StalkerEffect::begin(void) { - event_handler_hook_use(eventHandlerHook); - LEDMode::begin(); -} - -void StalkerEffect::init(void) { +void StalkerEffect::onActivate(void) { memset(map_, 0, sizeof(map_)); } @@ -59,7 +55,7 @@ void StalkerEffect::update(void) { for (byte c = 0; c < COLS; c++) { uint8_t step = map_[r][c]; if (step) { - LEDControl.setCrgbAt(r, c, variant->compute(&step)); + ::LEDControl.setCrgbAt(r, c, variant->compute(&step)); } if (time_out) { @@ -67,7 +63,7 @@ void StalkerEffect::update(void) { } if (!map_[r][c]) - LEDControl.setCrgbAt(r, c, (cRGB) { + ::LEDControl.setCrgbAt(r, c, (cRGB) { 0, 0, 0 }); } diff --git a/src/Kaleidoscope/LED-Stalker.h b/src/Kaleidoscope/LED-Stalker.h index f4764b11..99caed29 100644 --- a/src/Kaleidoscope/LED-Stalker.h +++ b/src/Kaleidoscope/LED-Stalker.h @@ -31,15 +31,16 @@ class StalkerEffect : public LEDMode { virtual cRGB compute(uint8_t *step) = 0; }; - StalkerEffect(void); - - void begin(void) final; - void init(void) final; - void update(void) final; + StalkerEffect(void) {} static ColorComputer *variant; static uint16_t step_length; + protected: + void setup(void) final; + void onActivate(void) final; + void update(void) final; + private: static uint32_t step_end_time_; static uint8_t map_[ROWS][COLS];