-
Notifications
You must be signed in to change notification settings - Fork 259
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 focus command for retreiving a list of installed LED effects #1387
Conversation
8322663
to
07a6834
Compare
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.
On a side note, I noticed that there are several plugins that don't implement onNameQuery
. Is that something to be fixed sometime, or is there a specific use case where that's needed for certain plugins?
plugins/Kaleidoscope-LED-ActiveLayerKeys/src/kaleidoscope/plugin/LED-ActiveLayerKeys.cpp
Outdated
Show resolved
Hide resolved
c23d593
to
d70a15b
Compare
I wanted the answer to be "check |
fb579dc
to
288ec12
Compare
I had that change ready to be committed 😅 Doesn't change that I can't tell in what scenarios it is or isn't important for the know to know about it. I'll leave that up to you |
The basics are implemented in all LED mode plugins. Example output using the M100 example sketch:
For the plugin to be useful for displaying LED effect names in Chrysalis, some configuration options might need to be included, for the |
6c92fbd
to
d9d113c
Compare
Nice! It does seem like it makes sense to be able to (optionally) specify an additional string for at least the SolidColor LED effect. I wonder if it's worth implementing something in the base class to let the user pass in a descriptive string in the constructor or with another method call and then having the base class able to respond with that in preference to the hardcoded name. Given that, it might make sense to refactor onNameQuery into the base class and to pull the name from a string baked into the plugin so we can reuse it for this |
I like the idea of implementing it in the base class. Right now every plugin has a few nearly identical lines, just to make this work. Moving the LED effect name to a variable allows for deduplicating lines as well as adds flexibility for including parameters, like for Will look into that soon. |
There's something I have yet to figure out about the constuctor arguments, but this new design seems to be working great.
One question: should led modes that haven't got a name specified return a default (empty?) string? With this new design, that can be easily achieved in LEDModeInterface.h |
Since the goal is to match up these names to the LED effect list in a desktop app like Chrysalis, I think we want a straight one to one mapping between effects and names ordered the same as they are on the device |
3d09ab7
to
8621191
Compare
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 implemented and tested the led mode name in just about all the relevant plugins now. The only exceptions are Jukebox and Miami plugins, because with my limited understanding of C++, I failed to figure out how to implement it in those.
On a side note: when I tried getting Tricolor to work, I got errors that I failed to resolve and at this point I'm not even sure if Tricolor is even meant to be used as a plugin.
plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.cpp
Outdated
Show resolved
Hide resolved
I'm not sure what I need to change in order to get those failing checks to pass. I would appreciate some help :) |
Oh. I think the issue here is that you're essentially introducing a focus dependency in the core that has not previously existed. I think you probably want to have onLedEffectQuery return a pointer |
The api expects hooks to return an if (inputMatchesCommand(input, cmd_led_modes)) {
const char *ledModeName;
kaleidoscope::Hooks::onLedEffectQuery(ledModeName);
::Focus.send(ledModeName, '\n');
return EventHandlerResult::EVENT_CONSUMED;
} This resulted in only a single LED mode being sent back. After hours of debugging, the simplicity of the problem struck me: I could try to make it a list of strings that gets updated, but that seems far from efficient. It also doesn't solve the other problem that is reported in CI, that the sketch becomes too large for the Model01. An alternative solution might be to update the hooks API to support callback functions and supply a callback that calls |
I think this patch gets us what we want in terms of flow, using the callback. Before it can land, I need to make sure we cut down the code size for AVR a bit. I've got a potential refactor I just need to test out. |
892d8b9
to
3f30812
Compare
void ledModeHandler_(const __FlashStringHelper *name) { | ||
Runtime.serialPort().println(name); | ||
} |
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.
Shouldn't this return EventHandlerResult::OK
, similar to ::Focus.sendName
?
Even if it doesn't, with the current signature of onLedEffectQuery
we might as well rename ::Focus.sendName
to ::Focus.sendLine
and use that, rather than having a handler method that does almost exactly the same :)
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.
EventHandlerResult::OK is something that gets returned by the actual EventHandler, which, in this case, is onLedEffectQuery
This is made more confusing than it should be by me misnaming the callback that prints out the LED mode ledModeHandler_
rather than sendLedModeCallback_
or something like that.
And I think I agree more with your comment down-conversation about moving the 'unnamed mode' guard into the callback than about reusing sendName as the callback.
I didn't realize that with the signature const __FlashStringHelper *name
we could also pass in regular in-memory strings and that everything would work.)
(I do think sendName should get refactored, but let's tackle that outside this PR)
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.
This is made more confusing than it should be by me misnaming the callback that prints out the LED mode
ledModeHandler_
rather thansendLedModeCallback_
or something like that.
I agree. I'll rename the method
plugins/Kaleidoscope-LEDEffects/src/kaleidoscope/plugin/Jukebox.cpp
Outdated
Show resolved
Hide resolved
38d6784
to
e0c744d
Compare
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]>
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]>
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]>
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]>
e0c744d
to
b08125e
Compare
Signed-off-by: Evy Bongers <[email protected]>
All of them are implemented now. Only thing is that the Tricolor effects (Jukebox and Miami) don't yet support setting a custom name.
|
Reading through the code, it's weird to me that we're ending up with an underscore prefixed lowerCamelCase _ledModeName pointer as an argument to the constructor, when all the other constructor params are snake_case and that we're ending up with a lowerCamelCase protected The style guide isn't super helpful for the constructor args, but for members, it says we do want 'em snake cased and that if they're not public, they should have trailing _s.
I think I'd have expected the constructors to look more like:
and that we should end up with the member looking like this: |
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
I'll update that. I mostly focussed on getting code to work and for the parts of the style guide I was already aware of, I've tried to stick to it, but I certainly haven't read the full style guide. Thank you for pointing that out.
👍🏻 |
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
Signed-off-by: Evy Bongers <[email protected]>
@EvyBongers - just that one question from this last review. Other than that, I just want to run it on hardware, then I'm happy to merge. Thanks so much for your work on this! |
Signed-off-by: Evy Bongers <[email protected]>
…boardio#1387) * Implement focus command `led.modes` for querying LED modes Signed-off-by: Evy Bongers <[email protected]>
No description provided.