From 31bbd890c4bfd455b42e760f040ff71eca81732a Mon Sep 17 00:00:00 2001 From: "James N. V. Cash" Date: Fri, 15 Dec 2017 11:38:52 -0500 Subject: [PATCH] Mark the layout "dirty" on focus hook change, so it updates Previously, when using the Focus hook to change the LED Colormap, one would need to trigger a refresh by switching layers or toggling LED themes --- src/Kaleidoscope/Colormap.cpp | 7 ++++++- src/Kaleidoscope/Colormap.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Kaleidoscope/Colormap.cpp b/src/Kaleidoscope/Colormap.cpp index cfa6e502..2f8b481f 100644 --- a/src/Kaleidoscope/Colormap.cpp +++ b/src/Kaleidoscope/Colormap.cpp @@ -29,6 +29,7 @@ namespace kaleidoscope { uint16_t ColormapEffect::map_base_; uint8_t ColormapEffect::max_layers_; uint8_t ColormapEffect::last_highest_layer_; +bool ColormapEffect::dirty_ = false; void ColormapEffect::setup(void) { Kaleidoscope.use(&::EEPROMSettings, &::LEDPaletteTheme); @@ -49,9 +50,10 @@ void ColormapEffect::onActivate(void) { } void ColormapEffect::update(void) { - if (Layer.top() == last_highest_layer_) + if (Layer.top() == last_highest_layer_ && !dirty_) return; + dirty_ = false; onActivate(); } @@ -66,6 +68,9 @@ bool ColormapEffect::focusHook(const char *command) { } bool ColormapEffect::focusHookLayerwise(const char *command) { + // We might set dirty unneccessarily sometimes, if using this hook to read + // The usual case for this hook is updating though, so this is probably okay + dirty_ = true; return ::LEDPaletteTheme.themeLayerFocusHandler(command, PSTR("colormap.layer"), map_base_, max_layers_); } diff --git a/src/Kaleidoscope/Colormap.h b/src/Kaleidoscope/Colormap.h index d385e4db..36b98a2f 100644 --- a/src/Kaleidoscope/Colormap.h +++ b/src/Kaleidoscope/Colormap.h @@ -41,6 +41,7 @@ class ColormapEffect : public LEDMode { static uint8_t last_highest_layer_; static uint8_t max_layers_; static uint16_t map_base_; + static bool dirty_; }; }