aboutsummaryrefslogtreecommitdiff
path: root/Model01-Firmware.ino
diff options
context:
space:
mode:
Diffstat (limited to 'Model01-Firmware.ino')
-rw-r--r--Model01-Firmware.ino101
1 files changed, 73 insertions, 28 deletions
diff --git a/Model01-Firmware.ino b/Model01-Firmware.ino
index aac0431..b45f626 100644
--- a/Model01-Firmware.ino
+++ b/Model01-Firmware.ino
@@ -140,60 +140,105 @@ typedef enum {
Lnch, Wind, View,
Ms, MsB, MsW,
Func,
+ Num,
+ NumBreathe,
COLOR_COUNT,
-} color_enum;
+} 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 cRGB _colors[], const color_enum _map[][ROWS][COLS]) : colors(_colors), map(_map) { }
+ DakkarColor(
+ const color_index_map _map,
+ const color_src_array _colors
+ ) : map(_map),
+ color_sources(_colors) {}
private:
- const cRGB *colors;
- const color_enum (*map)[ROWS][COLS];
+ 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, colors[map[layer][r][c]]);
+ LEDControl.setCrgbAt(r, c, getColor(layer,r,c));
}
}
}
void refreshAt(byte r, byte c) final {
- LEDControl.setCrgbAt(r, c, colors[map[Layer.top()][r][c]]);
+ LEDControl.setCrgbAt(r, c, getColor(Layer.top(),r,c));
}
};
#include "keymap-wrapper.h"
-static constexpr cRGB dark_colors[COLOR_COUNT] =
+const cRGB num_breathe() { return breath_compute(170); }
+
+#define D_C(r,g,b) ((DakkarColor::colorSrc){ \
+ .value_or_function = DakkarColor::colorSrc::VALUE, \
+ .vf = { .value = CRGB(r,g,b) } \
+})
+#define D_F(f) ((DakkarColor::colorSrc){ \
+ .value_or_function = DakkarColor::colorSrc::FUNCTION, \
+ .vf = { .function = f } \
+})
+
+static constexpr DakkarColor::colorSrc dark_colors[COLOR_COUNT] =
{
- [Off] = CRGB(0,0,0),
- [Base] = CRGB(0,0,0),
- [Lnch] = CRGB(0,0,150),
- [Wind] = CRGB(150,0,0),
- [View] = CRGB(0,150,0),
- [Ms] = CRGB(100,100,0),
- [MsB] = CRGB(50,0,50),
- [MsW] = CRGB(0,50,50),
- [Func] = CRGB(100,100,100),
+ [Off] = D_C(0,0,0),
+ [Base] = D_C(0,0,0),
+ [Lnch] = D_C(0,0,150),
+ [Wind] = D_C(150,0,0),
+ [View] = D_C(0,150,0),
+ [Ms] = D_C(100,100,0),
+ [MsB] = D_C(50,0,50),
+ [MsW] = D_C(0,50,50),
+ [Func] = D_C(100,100,150),
+ [Num] = D_C(150,0,0),
+ [NumBreathe] = D_F(num_breathe),
};
-static constexpr cRGB bright_colors[COLOR_COUNT] =
+static constexpr DakkarColor::colorSrc bright_colors[COLOR_COUNT] =
{
- [Off] = CRGB(0,0,0),
- [Base] = CRGB(50,50,50),
- [Lnch] = CRGB(0,0,100),
- [Wind] = CRGB(100,0,0),
- [View] = CRGB(0,100,0),
- [Ms] = CRGB(50,50,0),
- [MsB] = CRGB(30,0,30),
- [MsW] = CRGB(0,30,30),
- [Func] = CRGB(50,50,80),
+ [Off] = D_C(0,0,0),
+ [Base] = D_C(50,50,50),
+ [Lnch] = D_C(0,0,100),
+ [Wind] = D_C(100,0,0),
+ [View] = D_C(0,100,0),
+ [Ms] = D_C(50,50,0),
+ [MsB] = D_C(30,0,30),
+ [MsW] = D_C(0,30,30),
+ [Func] = D_C(50,50,80),
+ [Num] = D_C(100,0,0),
+ [NumBreathe] = D_F(num_breathe),
};
-static DakkarColor DakkarColorDark(dark_colors,color_keymaps);
-static DakkarColor DakkarColorBright(bright_colors,color_keymaps);
+static DakkarColor DakkarColorDark(color_keymaps,dark_colors);
+static DakkarColor DakkarColorBright(color_keymaps,bright_colors);
/** versionInfoMacro handles the 'firmware version info' macro
* When a key bound to the macro is pressed, this macro