From cd8a87ec47ce46183e8837a12085d86dccd0373f Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 30 Mar 2017 11:56:49 +0200 Subject: [PATCH] Restart the cycle early if the palette does not change Fixes #3. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/FingerPainter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Kaleidoscope/FingerPainter.cpp b/src/Kaleidoscope/FingerPainter.cpp index fe8073ab..a6613184 100644 --- a/src/Kaleidoscope/FingerPainter.cpp +++ b/src/Kaleidoscope/FingerPainter.cpp @@ -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;