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 <kaleidoscope@gergo.csillger.hu>
pull/389/head
Gergely Nagy 7 years ago
parent 7a582f3c4b
commit 3fdbc72f81

@ -44,7 +44,8 @@ void ColormapEffect::max_layers(uint8_t max_) {
void ColormapEffect::onActivate(void) { void ColormapEffect::onActivate(void) {
last_highest_layer_ = Layer.top(); 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) { void ColormapEffect::update(void) {
@ -55,7 +56,8 @@ void ColormapEffect::update(void) {
} }
void ColormapEffect::refreshAt(byte row, byte col) { 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) { bool ColormapEffect::focusHook(const char *command) {

Loading…
Cancel
Save