aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2019-02-10 17:07:22 +0000
committerdakkar <dakkar@thenautilus.net>2019-02-10 17:07:22 +0000
commit6111f5261f60410bda5bd1a7db98ad40d82e9cd3 (patch)
treebe515a5da229eff60bdfe38e98ca4ff2050f3588
parentmixed static / functional colors (diff)
downloadkeyboardio-model01-6111f5261f60410bda5bd1a7db98ad40d82e9cd3.tar.gz
keyboardio-model01-6111f5261f60410bda5bd1a7db98ad40d82e9cd3.tar.bz2
keyboardio-model01-6111f5261f60410bda5bd1a7db98ad40d82e9cd3.zip
move DakkarColor to its own file
-rw-r--r--DakkarColor.h50
-rw-r--r--Model01-Firmware.ino50
-rw-r--r--keymap-wrapper.h2
3 files changed, 52 insertions, 50 deletions
diff --git a/DakkarColor.h b/DakkarColor.h
new file mode 100644
index 0000000..17a93cb
--- /dev/null
+++ b/DakkarColor.h
@@ -0,0 +1,50 @@
+#pragma once
+
+class DakkarColor: public kaleidoscope::plugin::LEDMode {
+public:
+ typedef const cRGB (*color_function)();
+
+ struct colorSrc {
+ enum { VALUE, FUNCTION };
+ uint8_t value_or_function;
+ union {
+ cRGB value;
+ color_function function;
+ } vf;
+ };
+
+ typedef const uint8_t (*color_index_map)[ROWS][COLS];
+ typedef const colorSrc *color_src_array;
+
+ DakkarColor(
+ const color_index_map _map,
+ const color_src_array _colors
+ ) : map(_map),
+ color_sources(_colors) {}
+private:
+ const color_index_map map;
+ const color_src_array color_sources;
+
+ cRGB getColor(uint8_t l, uint8_t r, uint8_t c) {
+ uint8_t index = map[l][r][c];
+ colorSrc color_src = color_sources[index];
+ if (color_src.value_or_function == colorSrc::VALUE) {
+ return color_src.vf.value;
+ }
+ else {
+ return color_src.vf.function();
+ }
+ }
+protected:
+ void update(void) final {
+ uint8_t layer = Layer.top();
+ for (uint8_t r = 0; r < ROWS; r++) {
+ for (uint8_t c = 0; c < COLS; c++) {
+ LEDControl.setCrgbAt(r, c, getColor(layer,r,c));
+ }
+ }
+ }
+ void refreshAt(byte r, byte c) final {
+ LEDControl.setCrgbAt(r, c, getColor(Layer.top(),r,c));
+ }
+};
diff --git a/Model01-Firmware.ino b/Model01-Firmware.ino
index b45f626..5045e3e 100644
--- a/Model01-Firmware.ino
+++ b/Model01-Firmware.ino
@@ -145,56 +145,8 @@ typedef enum {
COLOR_COUNT,
} color_index;
-class DakkarColor: public kaleidoscope::plugin::LEDMode {
-public:
- typedef const cRGB (*color_function)();
-
- struct colorSrc {
- enum { VALUE, FUNCTION };
- uint8_t value_or_function;
- union {
- cRGB value;
- color_function function;
- } vf;
- };
-
- typedef const color_index (*color_index_map)[ROWS][COLS];
- typedef const colorSrc *color_src_array;
-
- DakkarColor(
- const color_index_map _map,
- const color_src_array _colors
- ) : map(_map),
- color_sources(_colors) {}
-private:
- const color_index_map map;
- const color_src_array color_sources;
-
- cRGB getColor(uint8_t l, uint8_t r, uint8_t c) {
- color_index index = map[l][r][c];
- colorSrc color_src = color_sources[index];
- if (color_src.value_or_function == colorSrc::VALUE) {
- return color_src.vf.value;
- }
- else {
- return color_src.vf.function();
- }
- }
-protected:
- void update(void) final {
- uint8_t layer = Layer.top();
- for (uint8_t r = 0; r < ROWS; r++) {
- for (uint8_t c = 0; c < COLS; c++) {
- LEDControl.setCrgbAt(r, c, getColor(layer,r,c));
- }
- }
- }
- void refreshAt(byte r, byte c) final {
- LEDControl.setCrgbAt(r, c, getColor(Layer.top(),r,c));
- }
-};
-
#include "keymap-wrapper.h"
+#include "DakkarColor.h"
const cRGB num_breathe() { return breath_compute(170); }
diff --git a/keymap-wrapper.h b/keymap-wrapper.h
index ce7a507..cc58545 100644
--- a/keymap-wrapper.h
+++ b/keymap-wrapper.h
@@ -12,7 +12,7 @@
#define CK(k,c) c
#define ColorKeymaps(layers...) \
- static constexpr color_index color_keymaps[][ROWS][COLS] = { layers };
+ static constexpr uint8_t color_keymaps[][ROWS][COLS] = { layers };
#include "keymaps.h"