-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Feature backlight #904
Feature backlight #904
Conversation
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.
Nice job on this @bortoz, clean implementation of the feature. Here are some initial changes/thoughts on this 👍
@Nicell I have updated the code based on your comments. |
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.
A few more things I noticed. Excited to get this added to ZMK. Thanks for the quick update on this.
FWIW, I built your fork to my board, works like a charm |
Thanks for your feedback @htang014! |
35a0a93
to
e5c4e3a
Compare
93d5fcb
to
8de01ce
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.
Two small link changes (#911 related) and a merge conflict fix. Otherwise, this all looks good to me. I'd like to have one more set of eyes over it before a merge though.
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 think there may be some off by one errors in the brightness level configs and/or calculations.
Also, check that ZMK_BACKLIGHT_USB
works. I might be missing something, but it looks like the current code won't compile with that option enabled.
|
||
static int on_keymap_binding_released(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) { | ||
return ZMK_BEHAVIOR_OPAQUE; |
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.
Not something to change in this commit, but it seems a bit silly that we require a released callback for behaviors that only do something on press.
@petejohanson maybe we could change z_impl_behavior_keymap_binding_released
so it returns ZMK_BEHAVIOR_OPAQUE
instead of -ENOTSUP
if no release callback is set?
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 think perhaps returning that is still valid, but the keymap code could better handle that errno specifically.
315b21a
to
b4f8773
Compare
@petejohanson I made a PR: zmkfirmware/zephyr#7 |
24a22b0
to
d83f220
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 whole, this looks great!
A few minor comments.
|
||
static int on_keymap_binding_released(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) { | ||
return ZMK_BEHAVIOR_OPAQUE; |
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 think perhaps returning that is still valid, but the keymap code could better handle that errno specifically.
1fbe79e
to
05013ec
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.
A few minor follow up thoughts. Thanks again!
I'll have test hardware for this soon.
docs/docs/features/backlight.md
Outdated
Backlight is always added to a board, not a shield. | ||
If you have a shield with backlight, you must add a `boards/` directory within your shield folder to define the backlight individually for each board that supports the shield. | ||
Inside the `boards/` folder, you define a `<board>.overlay` for each different board. |
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.
Thinking about this more, since we have the GPIO backed driver available that should be board agnostic, I wonder if we should be documenting and suggesting:
- Add GPIO backlight nodes/compatibles to shields.
- For tested boards used w/ the shield, add a
shield/foo/boards/bar.overlay
to override and add the board-specific PWM nodes.
Doing so will ensure a shield would have reasonable "fallback" backlight on some new board used w/ a given shield.
Thoughts?
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 think it's a good idea
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.
Added a note about that
Hi Pete, we can send you one of our boards equipped for this backlighting stuff if you want |
I actually snagged a revlp recently so that:
I have the resistors en route right now so I can solder the final piece and test this. Thanks though! |
3291ae9
to
06d6daa
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.
Few follow up thoughts, tested this and it works great!
a3fc437
to
7efbd98
Compare
Rebased to resolve a conflict |
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.
Thanks so much for your work on this!
This PR adds support for single color LED backlighting. The current implementation supports basic behaviors, such as increase/decrease brightness and toggle on/off.
I also added some useful configurations to increase power efficiency such as turning off the backlight when the USB is disconnected or when the board goes into idle state.
Finally I updated the documentation and the power profiler with the new changes.