-
Notifications
You must be signed in to change notification settings - Fork 280
Add EEPROM and focus support to ColormapOverlay #1434
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
base: master
Are you sure you want to change the base?
Add EEPROM and focus support to ColormapOverlay #1434
Conversation
| } | ||
|
|
||
| EventHandlerResult ColormapOverlay::onFocusEvent(const char *input) { | ||
| return ::LEDPaletteTheme.themeFocusEvent(input, PSTR("colormap.overlay"), map_base_, no_themes_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
colormap.overlay seems like the most logical focus command to me. Let me know what you think.
|
@EvyBongers did you end up testing this on hardware? |
|
I completely forgot about this. I'll see about testing it today |
|
So, I finally got around to testing this. The command returns the palette indexes as expected, but setting the indexes doesn't yet work 🤔 |
|
So, I dug a little deeper to see what I was missing. I thought I had a quick fix by calling on The confusing part is that Colormap-Overlay (seemed to) need to call Closing this for now |
|
Reopened because EEPROM supports needs to be added anyway and EEPROM and focus support should land together. |
|
Just found a comment about this on Discord. Cross-posting to have all of this together.
|
41ea3cb to
912fc39
Compare
|
@obra I'm continued worked on this and I have a feeling I'm getting close to having a first draft that can actually compile, but I just found that my idea of using At first glance it looks like implementing this in FocusSerial is as easy adding this bit of code. Can I add that as part of this PR, or would you prefer having a separate PR for that? void read(int8_t &i8) {
i8 = Runtime.serialPort().parseInt();
}
void read(int16_t &i16) {
i16 = Runtime.serialPort().parseInt();
} |
|
Just pull it out to a separate commit and I'm good :)
…On Tue, Mar 4, 2025 at 1:42 PM Evy Bongers ***@***.***> wrote:
@obra <https://github.com/obra> I'm continued worked on this and I have a
feeling I'm getting close to having a first draft that can actually
compile, but I just found that my idea of using -1 for keys that don't
have an overlay color isn't actually supported by FocusSerial at this
point. See my comments here:
https://github.com/EvyBongers/Kaleidoscope/blob/8db281269e9bf9d2b1cb97c6162f5aa434e45050/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.cpp#L117-L120
At first glance it looks like implementing this in FocusSerial is as easy
adding this bit of code. Can I add that as part of this PR, or would you
prefer having a separate PR for that?
void read(int8_t &i8) {
i8 = Runtime.serialPort().parseInt();
}
void read(int16_t &i16) {
i16 = Runtime.serialPort().parseInt();
}
—
Reply to this email directly, view it on GitHub
<#1434 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAALC2AH75N23PY24JSKBID2SYM57AVCNFSM6AAAAABKYKWNE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJZGAYDKMRWGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: EvyBongers]*EvyBongers* left a comment
(keyboardio/Kaleidoscope#1434)
<#1434 (comment)>
@obra <https://github.com/obra> I'm continued worked on this and I have a
feeling I'm getting close to having a first draft that can actually
compile, but I just found that my idea of using -1 for keys that don't
have an overlay color isn't actually supported by FocusSerial at this
point. See my comments here:
https://github.com/EvyBongers/Kaleidoscope/blob/8db281269e9bf9d2b1cb97c6162f5aa434e45050/plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.cpp#L117-L120
At first glance it looks like implementing this in FocusSerial is as easy
adding this bit of code. Can I add that as part of this PR, or would you
prefer having a separate PR for that?
void read(int8_t &i8) {
i8 = Runtime.serialPort().parseInt();
}
void read(int16_t &i16) {
i16 = Runtime.serialPort().parseInt();
}
—
Reply to this email directly, view it on GitHub
<#1434 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAALC2AH75N23PY24JSKBID2SYM57AVCNFSM6AAAAABKYKWNE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJZGAYDKMRWGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
8db2812 to
2a6ac62
Compare
Signed-off-by: Evy Bongers <[email protected]>
2a6ac62 to
ae4ee9c
Compare
…lay/Focus Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
5113820 to
22d8790
Compare
plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.cpp
Outdated
Show resolved
Hide resolved
|
Sure!
…On Tue, Mar 11, 2025 at 12:02 PM Evy Bongers ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.cpp
<#1434 (comment)>
:
> + // It appears that a call to ::LEDPaletteTheme.reserveThemes() is needed
+ // because it's where palette_base_ gets initialized. Since this plugin (and
+ // possibly others) don't actually use themes, requesting memory for storing
+ // themes doesn't make much sense. Maybe initialisation of palette_base_
+ // could be moved to a setup() method, though maybe the palette should be
+ // split from palette theme altogether?
That's fine by me. Want a separate PR for that too?
—
Reply to this email directly, view it on GitHub
<#1434 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAALC2BIP2L773YAYSO2ZSL2T4XKVAVCNFSM6AAAAABKYKWNE2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDMNZVHAYTAOBWGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
EvyBongers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally it now works in that the numpad keys in the default firmware always light up, regardless of the assigned keys and that the overlay colors can be changed/disabled over focus.
One thing I noticed is that, if an effect is active on layer 0, that effect keeps playing on all keys not in the numpad. To work around this, I could change the default sketch to apply color index 22 (for example, 16-22 should be black once users upgrade), so that this doesn't happen.
However, that isn't the only way the sketch now differs from the Numpad plugin. My tests showed that, when changing from the numpad back to layer 0, the overlay colors persisted until the point that the active color mode applied a different color. That is:
- With any mode that lights all leds, the leds follow the color mode logic and the colors applied by Colormap-Overlay don't persist.
- with modes like stalker of chase, the red color persists until the effect hits those keys and changes the leds
- with LEDOff the color of the overlay persists indefinitely
Please let me know what you think about this, as well as the comments I left on my TODOs
| namespace plugin { | ||
| uint16_t ColormapOverlay::map_base_; | ||
| uint16_t ColormapOverlay::overlays_base_; | ||
| uint8_t ColormapOverlay::max_overlays_ = 64; // TODO(EvyBongers): figure this out. How determine a good maximum? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@obra do you have a way to determine a good value here, or is this pure guess work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to be setting it to layer_count? that might (or might not) need an accessor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
layer_count is far too few, as an overlay only applies to a single key. Of course we could set it to layer_count * Runtime.device().numKeys(), but if anyone is gonna need that number of overlays, they're better off using Colormap rather than ColormapOverlay.
plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.cpp
Show resolved
Hide resolved
| uint8_t layer_ = (i - key_index_) / Runtime.device().numKeys(); | ||
|
|
||
| overlays_[overlay_count_] = Overlay(layer_, KeyAddr(key_index_), color_index_); | ||
| overlay_count_++; // TODO(EvyBongers): how to make sure that we don't exceed max_overlays_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to communicate over focus that an error occurred? I could just break the loop when the limit is reached, but I wonder if there are ways to report back why it happens. Of course, if the limit above were to be set to max_layers * numKeys this wouldn't happen, but that doesn't make any sense because if you're gonna set led colors on every key you should be using Colormap instead of Colormap-Overlay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there isn't currently. There should be.
plugins/Kaleidoscope-Colormap-Overlay/src/kaleidoscope/plugin/Colormap-Overlay.h
Outdated
Show resolved
Hide resolved
Signed-off-by: Evy Bongers <[email protected]>
I don't really feel strongly here.
This one, you should be able to fix by forcing the active led mode to do a full repaint, no?
|
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
| // TODO(anyone): For now we just break the loop. Once focus implements | ||
| // support for reporting back errors, this should report why we break | ||
| // the loop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a TODO to follow up on this discussion: #1434 (comment)
| Overlay *overlays_; | ||
| uint8_t overlay_count_; | ||
| static uint16_t overlays_base_; | ||
| static const uint8_t max_overlays_ = 64; // TODO(EvyBongers): figure this out. How determine a good maximum? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following up on #1434 (comment):
layer_count is far too few, as an overlay only applies to a single key. We could set it to layer_count * Runtime.device().numKeys(), but if anyone is gonna need that number of overlays, they're better off using Colormap rather than ColormapOverlay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. I think that starting at a fixed # like 64 seems fine. if we find folks needing it increased, we can do that.
| if (color_index_ >= 0 && color_index_ < ::LEDPaletteTheme.getPaletteSize() && | ||
| color_index_ != no_color_overlay) { | ||
| count++; | ||
| count++; // TODO(EvyBongers): how to make sure that we don't exceed max_overlays_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per your suggestion, I added a static_assert in the method above, but since I need to count the number if overlays here, it seems impossible to use that here. Any ideas on how I could validate that here? Or should I move the logic for finding all specified overlays to the macro below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have an obvious answer for you here. What happens if you just return when they've gone over the limit?
| // When settings are invalid, better to clean it all up to prevent unwanted things from happening | ||
| ::EEPROMSettings.invalidate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: #1434 (comment)
Is this the correct way to handle this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe so. the seal is taken care of automatically. and isValid is a whole-system level thing.
This should be the right pattern
EventHandlerResult Keyclick::onSetup() {
// Request storage space and load settings
bool success = ::EEPROMSettings.requestSliceAndLoadData(&settings_base_, &settings_);
// If settings weren't loaded successfully, use defaults
if (!success) {
settings_.enabled = true;
settings_.version = 0x01;
updateSettings();
}
Signed-off-by: Evy Bongers <[email protected]>
Just implemented this and verified that it works. |
Quick attempt to implement focus support in ColormapOverlay. I feel this should work, but I don't have my keyboard with me right now, so any debugging I'll have to do later.