-
-
Notifications
You must be signed in to change notification settings - Fork 39.6k
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
quantum: led: split out led_update_ports() for customization of led behaviour #14452
Conversation
LED state should never be modified; it will get out of sync with the host LED state. |
@fauxpark Only the copy inside An alternative would be to move the physical LED logic in |
The simple act of changing it will desync it. The KB/user level led state will no longer match the data that has been given to the keyboard. it will no longer be accurate. |
With "state" you mean the physical LED? |
But this does effect every board that uses the function. And it could definitely cause issues for other boards. Also, this will break any board that calls the |
Fair enough. |
I was thinking about suggesting something like that. At least, at the kb level. |
Ok, I'll update the PR then |
cfdbbee
to
7a85675
Compare
e858283
to
3b73801
Compare
3b73801
to
16d9f79
Compare
16d9f79
to
c188e95
Compare
Thank you for your contribution! |
I can't find what the PR was like initially, but in its current state it looks like an improvement to me. Certainly something deserving another chance. |
/unstale |
Needs a format pass, at the very least |
@drashna I tried to keep the changes minimal. The format issues are in the existing code. |
@drashna For some reason the same formatting is accepted with the old function but not the new one. |
Thank you for your contribution! |
I wonder if this can be improved so that the moonlander code gets a little simpler. The moonlander has 6 leds and largely foregoes |
Allow implementors of led_update_user() to modify the current led_state but still use the default functionality for writing the state to the respective PINs. This can be used to reuse one of the standard LEDs for a different usecase without having to reimplement all of that logic. Fixes qmk#13272
@joukewitteveen For example in // Use Bit-C LED to show NUM LOCK status
bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if (res) {
set_bitc_LED(led_state.num_lock ? LED_DIM : LED_OFF);
}
return res;
} would become // Use Bit-C LED to show NUM LOCK status
void led_update_ports(led_t led_state) {
set_bitc_LED(led_state.num_lock ? LED_DIM : LED_OFF);
} Looking at custom implementations of |
The outer #ifdef only really protects the inversion of led_state.raw which the compiler can easily optimize away if it is not needed.
b09a374
to
42fa8dd
Compare
Reading through this PR and its implementation, I must be missing something. Can I just confirm the intent -- this PR is asking for the ability to manipulate the Why can't your example of: // Use Bit-C LED to show NUM LOCK status
void led_update_ports(led_t led_state) {
set_bitc_LED(led_state.num_lock ? LED_DIM : LED_OFF);
} ...just become: // Use Bit-C LED to show NUM LOCK status
bool led_update_user(led_t led_state) {
set_bitc_LED(led_state.num_lock ? LED_DIM : LED_OFF);
return false;
} ...without the extra function? What problem are we actually trying to solve here? |
I see two reasons.
|
Thanks! |
Following qmk#14452, less boilerplate is needed to customize indicator led control.
Following #14452, less boilerplate is needed to customize indicator led control.
Following qmk#14452, less boilerplate is needed to customize indicator led control.
Allow implementors of led_update_user() to modify the current led_state
but still use the default functionality of led_update_kb().
This can be used to reuse one of the standard LEDs for a different
usecase without having to reimplement led_update_kb().
Fixes #13272
This is still missing updates to the docs and keymaps.
Will do those after a first round of feedback.
Issues Fixed or Closed by This PR
led_state
consumed byled_update_kb
fromled_update_user
#13272Checklist