Skip to content

feat(underglow): add update hook called immediately before writing to strip#3264

Open
jkorinth wants to merge 1 commit into
zmkfirmware:mainfrom
jkorinth:feature/rgb-underglow-update-hook
Open

feat(underglow): add update hook called immediately before writing to strip#3264
jkorinth wants to merge 1 commit into
zmkfirmware:mainfrom
jkorinth:feature/rgb-underglow-update-hook

Conversation

@jkorinth
Copy link
Copy Markdown

@jkorinth jkorinth commented Mar 1, 2026

Adds a hook that is called immediately before pixels are written to the led strip in rgb_underglow.c. The hook is implemented by a weak function to allow ZMK modules to overwrite it . The hook can perform modifications of the struct led_rgb array, e.g., to deactivate specific LEDs (see e.g., zmk-rgb-underglow-mask-leds for a working example).

PR check-list

  • Branch has a clean commit history
  • Additional tests are included, if changing behaviors/core code that is testable.
  • Proper Copyright + License headers added to applicable files (Generally, we stick to "The ZMK Contributors" for copyrights to help avoid churn when files get edited)
  • Pre-commit used to check formatting of files, commit messages, etc.
  • Includes any necessary documentation changes.

@jkorinth jkorinth force-pushed the feature/rgb-underglow-update-hook branch from d83278b to f228e1c Compare March 1, 2026 21:16
@jkorinth jkorinth force-pushed the feature/rgb-underglow-update-hook branch from f228e1c to 9e33a7a Compare March 1, 2026 21:18
@jkorinth jkorinth changed the title feat(rgb_underglow): add update hook called immediately before writing to strip feat(underglow): add update hook called immediately before writing to strip Mar 1, 2026
@jkorinth jkorinth marked this pull request as ready for review March 1, 2026 21:30
@jkorinth jkorinth requested a review from a team as a code owner March 1, 2026 21:30
@caksoylar
Copy link
Copy Markdown
Contributor

I like adding an approach similar to custom status screens in order to allow for custom underglow effects. (I don't know if this is the best architectural approach for it, other contributors would have a better idea.) That being said, wouldn't such custom effects also need the timing information, such as timestamp or time since last update?

It would also be nice if this was enabled by selecting a "custom" effect type, rather than overriding whatever the user has currently selected.

@jkorinth
Copy link
Copy Markdown
Author

jkorinth commented Mar 2, 2026

@caksoylar I think getting getting the timestamps would be more accurate if done from the hook side. Should not be an issue to maintain the last update timestamp there, I think.

But I didn't mean to override the effect, just adapt to specific hardware. E.g., selectively reduce brightness, fix leds that have a color tint/bias toward one color, or turn them off completely. I frequently need to do this for battery life optimization. Take the Reviung41 for example: the central top-side led is number 11 in the strip, so you can't easily turn off all the bottom-side leds but keep the center on.

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