From 912fc39c81fd1aaf9e9d64584e762eae1f0d44f0 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Wed, 13 Nov 2024 17:10:29 +0100 Subject: [PATCH] Add TODOs for implemending EEPROM and focus support Signed-off-by: Evy Bongers --- .../kaleidoscope/plugin/Colormap-Overlay.cpp | 26 +++++++++++++++++++ .../kaleidoscope/plugin/Colormap-Overlay.h | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) 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;