diff --git a/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.cpp b/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.cpp index e71adbe24..94eee92d7 100644 --- a/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.cpp +++ b/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.cpp @@ -31,6 +31,7 @@ namespace plugin { uint16_t ColormapOverlay::map_base_; void ColormapOverlay::setup() { + // TODO: check if a call to ::LEDPaletteTheme.reserveThemes() is actually needed map_base_ = ::LEDPaletteTheme.reserveThemes(1); } @@ -78,6 +79,31 @@ EventHandlerResult ColormapOverlay::beforeSyncingLeds() { return EventHandlerResult::OK; } +EventHandlerResult ColormapOverlay::onFocusEvent(const char *input) { + if (!Runtime.has_leds) + return EventHandlerResult::OK; + + const char *cmd = PSTR("colormap.overlay"); + + if (::Focus.inputMatchesHelp(input)) + return ::Focus.printHelp(cmd); + + if (!::Focus.inputMatchesCommand(input, cmd)) + return EventHandlerResult::OK; + + if (::Focus.isEOL()) { + // TODO: loop over all layers and keys, check if a color overlay is specified and return either overlay index or -1 + return EventHandlerResult::EVENT_CONSUMED; + } + + // TODO: loop over all layers and keys, for each read specified index and when it's >=0 store overlay in EEPROM + Runtime.storage().commit(); + + ::LEDControl.refreshAll(); + + return EventHandlerResult::EVENT_CONSUMED; +} + } // namespace plugin } // namespace kaleidoscope diff --git a/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.h b/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.h index 16a8d4a39..35104358a 100644 --- a/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.h +++ b/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.h @@ -75,10 +75,11 @@ class ColormapOverlay : public kaleidoscope::Plugin { EventHandlerResult onSetup(); EventHandlerResult beforeSyncingLeds(); + EventHandlerResult onFocusEvent(const char *input); private: static uint16_t map_base_; - Overlay const *overlays_; + Overlay const *overlays_; // TODO: store overlays in EEPROM uint8_t overlay_count_; cRGB selectedColor;