Restart the cycle early if the palette does not change

Fixes #3.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/389/head
Gergely Nagy 8 years ago
parent 8b6653d3c8
commit cd8a87ec47

@ -81,13 +81,19 @@ namespace KaleidoscopePlugins {
if (!key_toggled_on (keyState))
return Key_NoKey;
cRGB oldColor, newColor;
uint16_t location = row * COLS + col;
uint8_t colorIndex = EEPROM.read (colorBase + location);
if (colorIndex == 255)
colorIndex = 0;
EEPROM.get (paletteBase + colorIndex * sizeof (cRGB), oldColor);
colorIndex++;
if (colorIndex > 15)
colorIndex = 0;
EEPROM.get (paletteBase + colorIndex * sizeof (cRGB), newColor);
if (memcmp (&oldColor, &newColor, sizeof (cRGB)) == 0)
colorIndex = 0;
EEPROM.update (colorBase + location, colorIndex);
return Key_NoKey;

Loading…
Cancel
Save