aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2018-08-30 00:17:05 -0400
committerBrian Cully <bjc@kublai.com>2018-08-30 00:17:05 -0400
commit3442e117d41c3d77c980b918beb0c1d8411b272f (patch)
treec8e3ca9afbeed614a853596b374195baf3b60ef3 /src
downloadKaleidoscope-LayerHighlighter-3442e117d41c3d77c980b918beb0c1d8411b272f.tar.gz
Kaleidoscope-LayerHighlighter-3442e117d41c3d77c980b918beb0c1d8411b272f.zip
Initial commit.
Diffstat (limited to 'src')
-rw-r--r--src/Kaleidoscope-LayerHighlighter.cpp45
-rw-r--r--src/Kaleidoscope-LayerHighlighter.h18
2 files changed, 63 insertions, 0 deletions
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 <Kaleidoscope.h>
+
+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;
+}
diff --git a/src/Kaleidoscope-LayerHighlighter.h b/src/Kaleidoscope-LayerHighlighter.h
new file mode 100644
index 0000000..65ae483
--- /dev/null
+++ b/src/Kaleidoscope-LayerHighlighter.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include <Kaleidoscope.h>
+
+class LayerHighlighter : public kaleidoscope::Plugin {
+ public:
+ LayerHighlighter(uint8_t l): color(CRGB(160, 0, 0)), lockHue(170), layer(l) {}
+
+ cRGB color;
+ uint8_t lockHue;
+
+ kaleidoscope::EventHandlerResult onSetup(void);
+ kaleidoscope::EventHandlerResult afterEachCycle();
+
+ private:
+ const uint8_t layer;
+ static byte row, col;
+};