Conversation
| | `disconnected-brightness` | int | LED brightness in percent when the keyboard is not connected | 0 | | ||
| | `on-while-idle` | bool | Keep LEDs enabled even when the keyboard is idle and on battery power | false | | ||
|
|
||
| The `indicator` property must be one of the `HID_INDICATOR_*` values defined in [zmk/app/include/dt-bindings/zmk/hid_indicators.h](https://github.com/zmkfirmware/zmk/blob/main/app/include/dt-bindings/zmk/hid_indicators.h). You may also combine values with `|` to make the LED only be lit when multiple indicator states are active at the same time. |
There was a problem hiding this comment.
I wasn't sure if this should be "only light LED when all indicators is active" or "only light LED when any indicator is active", or if this is even a valid use case. (If anyone can think of a reason to want both options, I could add a property to switch between OR and AND.)
This adds a new zmk,indicator-leds device, which maps HID indicator states onto any devices that implement the LED driver API. This adds support for things like a caps lock LED. The name was chosen so that more drivers could be added later as zmk,indicator-*, for example a version that uses the LED strip API.
1c29afd to
0a01319
Compare
|
Example usage in a working board: https://github.com/joelspadin/zmk-keyboards/blob/0ba8648d2c4b8d6e2944f0afd5c3a9908fa3d5c6/boards/joelspadin/marten_numpad/marten_numpad.dts#L59 (That module also contains a slightly older copy of this driver.) |
petejohanson
left a comment
There was a problem hiding this comment.
Looks really good, generally. A few minor comments from a first pass.
| # Copyright (c) 2025 The ZMK Contributors | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| config ZMK_INDICATOR_LEDS |
There was a problem hiding this comment.
I'd like to start moving toward a more organize Kconfig structure, modeled off what Zephyr does, so moving these into a Kconfig.indicator_leds file which gets sources from here.
Doing so will help keep the "one giant Kconfig file" at bay a bit.
| return true; | ||
| } | ||
|
|
||
| LOG_ERR("Unhandled activity state %d", data->activity_state); |
There was a problem hiding this comment.
I prefer putting this in the default of the switch above.
There was a problem hiding this comment.
Not creating a default case was intentional. I don't know if we have the specific compiler option enabled for this, but if you switch on an enum and don't include a default case, then the compiler can warn/error if you do not have a case for every enum value. Then you get notified at compile time if someone adds a new value to the enum and forgets to update every switch block.
This adds a new zmk,indicator-leds device, which maps HID indicator states onto any devices that implement the LED driver API. This adds support for things like a caps lock LED.
The name was chosen so that more drivers could be added later as zmk,indicator-*, for example a version that uses the LED strip API.