From 3fdbc72f812b82f98194f1fe3baa3f0a3ecb1927 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 18 Aug 2017 18:24:24 +0200 Subject: [PATCH] Limit layers we work on to max_layers_ The plugin should not try to set the colors of a layer higher than `max_layers_`, because the colormap for that would be coming from an EEPROM area that is not ours, and result in weird colors at best. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/Colormap.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Kaleidoscope/Colormap.cpp b/src/Kaleidoscope/Colormap.cpp index 25a8264e..1c22cfd4 100644 --- a/src/Kaleidoscope/Colormap.cpp +++ b/src/Kaleidoscope/Colormap.cpp @@ -44,7 +44,8 @@ void ColormapEffect::max_layers(uint8_t max_) { void ColormapEffect::onActivate(void) { last_highest_layer_ = Layer.top(); - ::LEDPaletteTheme.updateHandler(map_base_, last_highest_layer_); + if (last_highest_layer_ <= max_layers_) + ::LEDPaletteTheme.updateHandler(map_base_, last_highest_layer_); } void ColormapEffect::update(void) { @@ -55,7 +56,8 @@ void ColormapEffect::update(void) { } void ColormapEffect::refreshAt(byte row, byte col) { - ::LEDPaletteTheme.refreshAt(map_base_, last_highest_layer_, row, col); + if (last_highest_layer_ <= max_layers_) + ::LEDPaletteTheme.refreshAt(map_base_, last_highest_layer_, row, col); } bool ColormapEffect::focusHook(const char *command) {