diff --git a/src/Kaleidoscope/Colormap.cpp b/src/Kaleidoscope/Colormap.cpp index 56da9c9e..25a8264e 100644 --- a/src/Kaleidoscope/Colormap.cpp +++ b/src/Kaleidoscope/Colormap.cpp @@ -28,6 +28,7 @@ namespace kaleidoscope { uint16_t ColormapEffect::map_base_; uint8_t ColormapEffect::max_layers_; +uint8_t ColormapEffect::last_highest_layer_; void ColormapEffect::setup(void) { Kaleidoscope.use(&::EEPROMSettings, &::LEDPaletteTheme); @@ -41,22 +42,20 @@ void ColormapEffect::max_layers(uint8_t max_) { map_base_ = ::LEDPaletteTheme.reserveThemes(max_layers_); } +void ColormapEffect::onActivate(void) { + last_highest_layer_ = Layer.top(); + ::LEDPaletteTheme.updateHandler(map_base_, last_highest_layer_); +} + void ColormapEffect::update(void) { - for (uint8_t l = 0; l < max_layers_; l++) { - if (!Layer.isOn(l)) - continue; + if (Layer.top() == last_highest_layer_) + return; - ::LEDPaletteTheme.updateHandler(map_base_, l); - } + onActivate(); } void ColormapEffect::refreshAt(byte row, byte col) { - for (uint8_t l = 0; l < max_layers_; l++) { - if (!Layer.isOn(l)) - continue; - - ::LEDPaletteTheme.refreshAt(map_base_, l, row, col); - } + ::LEDPaletteTheme.refreshAt(map_base_, last_highest_layer_, row, col); } bool ColormapEffect::focusHook(const char *command) { diff --git a/src/Kaleidoscope/Colormap.h b/src/Kaleidoscope/Colormap.h index 9709dd47..208cfab4 100644 --- a/src/Kaleidoscope/Colormap.h +++ b/src/Kaleidoscope/Colormap.h @@ -32,10 +32,12 @@ class ColormapEffect : public LEDMode { protected: void setup(void) final; + void onActivate(void) final; void update(void) final; void refreshAt(byte row, byte col) final; private: + static uint8_t last_highest_layer_; static uint8_t max_layers_; static uint16_t map_base_; };