From 912fc39c81fd1aaf9e9d64584e762eae1f0d44f0 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Wed, 13 Nov 2024 17:10:29 +0100 Subject: [PATCH 1/2] 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 e71adbe246..94eee92d74 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 16a8d4a396..35104358a8 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; From c72be427d90751ba6c613a13b505e1248311327c Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Tue, 18 Feb 2025 20:03:14 +0100 Subject: [PATCH 2/2] Implement focus reading colormap overlays Signed-off-by: Evy Bongers --- .../src/kaleidoscope/plugin/Colormap-Overlay.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 94eee92d74..37b9559c2b 100644 --- a/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.cpp +++ b/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.cpp @@ -92,11 +92,21 @@ EventHandlerResult ColormapOverlay::onFocusEvent(const char *input) { 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 + for (uint8_t layer = 0; layer < defaultcolormap::colormap_layers; layer++) { + for (int8_t i = 0; i < Runtime.device().numKeys(); i++) { + for (uint8_t overlay_index{0}; overlay_index < overlay_count_; ++overlay_index) { + Overlay overlay = overlays_[overlay_index]; + if ((overlay.addr == k) && (overlay.layer == top_layer)) { + ::Focus.send(overlay.palette_index); + } + } + ::Focus.send(-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 + // TODO: read all input, 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();