Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EEPROM and focus support to ColormapOverlay #1434

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading