From 0b96b74f7ac61a8665308cdb601ba8c73c6c72db Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 7 Aug 2019 13:31:49 +0100 Subject: switch to linear addressing --- DakkarColor.h | 23 ++++++++++++++--------- keymap-wrapper.h | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/DakkarColor.h b/DakkarColor.h index a42f9b1..71d858f 100644 --- a/DakkarColor.h +++ b/DakkarColor.h @@ -16,7 +16,7 @@ public: } vf; }; - typedef const uint8_t (*color_index_map)[ROWS][COLS]; + typedef const uint8_t (*color_index_map)[ROWS*COLS]; typedef const colorSrc *color_src_array; DakkarColor( @@ -28,8 +28,8 @@ 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]; + cRGB getColor(uint8_t layer, KeyAddr key_addr) { + uint8_t index = map[layer][key_addr.toInt()]; colorSrc color_src = color_sources[index]; if (color_src.value_or_function == colorSrc::VALUE) { return color_src.vf.value; @@ -41,13 +41,18 @@ private: 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)); - } + for (auto key_addr : KeyAddr::all()) { + LEDControl.setCrgbAt(key_addr, getColor(layer,key_addr)); } } - void refreshAt(byte r, byte c) final { - LEDControl.setCrgbAt(r, c, getColor(Layer.top(),r,c)); + void refreshAt(KeyAddr key_addr) final { + LEDControl.setCrgbAt(key_addr, getColor(Layer.top(),key_addr)); + } + // not sure why I need this here, but if I remove it, I get «virtual + // void kaleidoscope::plugin::LEDMode::refreshAt(byte, byte)' was + // hidden by 'virtual void DakkarColor::refreshAt(KeyAddr)' + // [-Woverloaded-virtual]» + DEPRECATED(ROW_COL_FUNC) virtual void refreshAt(byte row, byte col) { + refreshAt(KeyAddr(row, col)); } }; diff --git a/keymap-wrapper.h b/keymap-wrapper.h index 7e6f8b0..89909cb 100644 --- a/keymap-wrapper.h +++ b/keymap-wrapper.h @@ -16,7 +16,7 @@ #define CK(k,c) c #define ColorKeymaps(layers...) \ - static constexpr uint8_t color_keymaps[][ROWS][COLS] = { layers }; + static constexpr uint8_t color_keymaps[][ROWS*COLS] = { layers }; #include "keymaps.h" -- cgit v1.2.3