Skip to content

feat: Add LED indicator support#3239

Open
joelspadin wants to merge 1 commit intozmkfirmware:mainfrom
joelspadin:led-indicators
Open

feat: Add LED indicator support#3239
joelspadin wants to merge 1 commit intozmkfirmware:mainfrom
joelspadin:led-indicators

Conversation

@joelspadin
Copy link
Collaborator

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.

@joelspadin joelspadin requested review from a team as code owners February 14, 2026 22:46
| `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.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@joelspadin
Copy link
Collaborator Author

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 petejohanson added this to the v0.4.0 milestone Feb 27, 2026
Copy link
Contributor

@petejohanson petejohanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer putting this in the default of the switch above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair. Disregard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants