From 3442e117d41c3d77c980b918beb0c1d8411b272f Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Thu, 30 Aug 2018 00:17:05 -0400 Subject: Initial commit. --- src/Kaleidoscope-LayerHighlighter.cpp | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/Kaleidoscope-LayerHighlighter.cpp (limited to 'src/Kaleidoscope-LayerHighlighter.cpp') diff --git a/src/Kaleidoscope-LayerHighlighter.cpp b/src/Kaleidoscope-LayerHighlighter.cpp new file mode 100644 index 0000000..68c1984 --- /dev/null +++ b/src/Kaleidoscope-LayerHighlighter.cpp @@ -0,0 +1,45 @@ +#include "Kaleidoscope-LayerHighlighter.h" +#include "LEDUtils.h" +#include "layers.h" +#include "Kaleidoscope-LEDControl.h" + +#include + +byte LayerHighlighter::row = 255, LayerHighlighter::col = 255; + +kaleidoscope::EventHandlerResult LayerHighlighter::onSetup(void) { + return kaleidoscope::EventHandlerResult::OK; +} + +kaleidoscope::EventHandlerResult LayerHighlighter::afterEachCycle() { + if (!Layer.isOn(layer)) + return kaleidoscope::EventHandlerResult::OK; + + LEDControl.set_mode(LEDControl.get_mode_index()); + + for (uint8_t r = 0; r < ROWS; r++) { + for (uint8_t c = 0; c < COLS; c++) { + Key k = Layer.lookupOnActiveLayer(r, c); + Key layer_key = Layer.getKey(layer, r, c); + + if (k == LockLayer(layer)) { + row = r; + col = c; + } + + if ((k != layer_key) || (k == Key_NoKey)) { + LEDControl.refreshAt(r, c); + } else { + LEDControl.setCrgbAt(r, c, color); + } + } + } + + if (row > ROWS || col > COLS) + return kaleidoscope::EventHandlerResult::OK; + + cRGB lock_color = breath_compute(lockHue); + LEDControl.setCrgbAt(row, col, lock_color); + + return kaleidoscope::EventHandlerResult::OK; +} -- cgit v1.2.3