Merge pull request #8 from jamesnvc/update-on-focus

Mark the layout "dirty" on focus hook change, so it updates
pull/389/head
Gergely Nagy 7 years ago committed by GitHub
commit b4dd6706df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,6 +29,7 @@ namespace kaleidoscope {
uint16_t ColormapEffect::map_base_; uint16_t ColormapEffect::map_base_;
uint8_t ColormapEffect::max_layers_; uint8_t ColormapEffect::max_layers_;
uint8_t ColormapEffect::last_highest_layer_; uint8_t ColormapEffect::last_highest_layer_;
bool ColormapEffect::dirty_ = false;
void ColormapEffect::setup(void) { void ColormapEffect::setup(void) {
Kaleidoscope.use(&::EEPROMSettings, &::LEDPaletteTheme); Kaleidoscope.use(&::EEPROMSettings, &::LEDPaletteTheme);
@ -49,9 +50,10 @@ void ColormapEffect::onActivate(void) {
} }
void ColormapEffect::update(void) { void ColormapEffect::update(void) {
if (Layer.top() == last_highest_layer_) if (Layer.top() == last_highest_layer_ && !dirty_)
return; return;
dirty_ = false;
onActivate(); onActivate();
} }
@ -66,6 +68,9 @@ bool ColormapEffect::focusHook(const char *command) {
} }
bool ColormapEffect::focusHookLayerwise(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"), return ::LEDPaletteTheme.themeLayerFocusHandler(command, PSTR("colormap.layer"),
map_base_, max_layers_); map_base_, max_layers_);
} }

@ -41,6 +41,7 @@ class ColormapEffect : public LEDMode {
static uint8_t last_highest_layer_; static uint8_t last_highest_layer_;
static uint8_t max_layers_; static uint8_t max_layers_;
static uint16_t map_base_; static uint16_t map_base_;
static bool dirty_;
}; };
} }

Loading…
Cancel
Save