From f83ac78605bc3578aae805023310cd53f59ef5ae Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 30 Mar 2017 09:15:40 +0200 Subject: [PATCH] Add an (optional) default palette Fixes #1. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/FingerPainter.cpp | 12 ++++++++++++ src/Kaleidoscope/FingerPainter.h | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/Kaleidoscope/FingerPainter.cpp b/src/Kaleidoscope/FingerPainter.cpp index 2b68ee79..fe8073ab 100644 --- a/src/Kaleidoscope/FingerPainter.cpp +++ b/src/Kaleidoscope/FingerPainter.cpp @@ -24,6 +24,7 @@ namespace KaleidoscopePlugins { uint16_t FingerPainter::paletteBase; uint16_t FingerPainter::colorBase; bool FingerPainter::editMode; + const cRGB *FingerPainter::defaultPalette; FingerPainter::FingerPainter (void) { } @@ -130,6 +131,17 @@ namespace KaleidoscopePlugins { return true; } + if (Serial.peek() == 'd') { + Serial.read (); + if (!defaultPalette) + return true; + + for (uint8_t i = 0; i < 16; i++) { + EEPROM.put (paletteBase + i * sizeof (cRGB), defaultPalette[i]); + } + return true; + } + uint8_t i = 0; while (i < 16 && Serial.peek() != '\n') { cRGB color; diff --git a/src/Kaleidoscope/FingerPainter.h b/src/Kaleidoscope/FingerPainter.h index 49bf5d6b..07ad2967 100644 --- a/src/Kaleidoscope/FingerPainter.h +++ b/src/Kaleidoscope/FingerPainter.h @@ -33,6 +33,8 @@ namespace KaleidoscopePlugins { static void toggleEdit (void); static bool focusHook (const char *command); + static const cRGB *defaultPalette; + private: static uint16_t paletteBase; static uint16_t colorBase; @@ -48,3 +50,23 @@ extern KaleidoscopePlugins::FingerPainter FingerPainter; #define FOCUS_HOOK_FINGERPAINTER FOCUS_HOOK(FingerPainter.focusHook, \ "fingerpainter.palette\n" \ "fingerpainter.toggle") + +#define FINGERPAINTER_PALETTE_EGA (const cRGB[]) { \ + CRGB (0x00, 0x00, 0x00), \ + CRGB (0x00, 0x00, 0xaa), \ + CRGB (0x00, 0xaa, 0x00), \ + CRGB (0x00, 0xaa, 0xaa), \ + CRGB (0xaa, 0x00, 0x00), \ + CRGB (0xaa, 0x00, 0xaa), \ + CRGB (0xaa, 0x55, 0x00), \ + CRGB (0xaa, 0xaa, 0xaa), \ + \ + CRGB (0x55, 0x55, 0x55), \ + CRGB (0x55, 0x55, 0xff), \ + CRGB (0x55, 0xff, 0x55), \ + CRGB (0x55, 0xff, 0xff), \ + CRGB (0xff, 0x55, 0x55), \ + CRGB (0xff, 0x55, 0xff), \ + CRGB (0xff, 0xff, 0x55), \ + CRGB (0xff, 0xff, 0xff) \ + }