Skip to content

ws2812: add vcc enable pin support#26215

Open
damex wants to merge 1 commit into
qmk:developfrom
damex:feat/ws2812-vcc-enable-pin
Open

ws2812: add vcc enable pin support#26215
damex wants to merge 1 commit into
qmk:developfrom
damex:feat/ws2812-vcc-enable-pin

Conversation

@damex

@damex damex commented May 16, 2026

Copy link
Copy Markdown

Description

opt in mechanism for boards that gate the WS2812 chain vcc rail through one or more gpio.
ws2812 draw ~1ma each even when displaying black
long chains dominate standby drain on battery powered keyboards. configured via ws2812.vcc_enable_pins (array)
and ws2812.vcc_active_low (bool) in keyboard.json.

drivers/led/ws2812.{c,h}: new ws2812_set_power(bool on), compiled only when WS2812_VCC_ENABLE_PINS is defined. polarity from WS2812_VCC_ACTIVE_LOW.
pins driven together in lockstep.
The driver dedupes consecutive identical calls and lazily flips pins to output (write-then-set-output to avoid an active-low glitch on the first call).

quantum/rgb_matrix/rgb_matrix_drivers.{c,h} and
quantum/rgblight/rgblight_drivers.{c,h}:
optional set_power vtable entry. ws2812 driver wires it only when WS2812_VCC_ENABLE_PINS is defined; other drivers and unconfigured ws2812 builds leave NULL. callers branch on set_power != NULL so unconfigured boards keep their existing render-zero-and-flush behavior.

quantum/rgb_matrix/rgb_matrix.c: drive set_power from rgb_task_start with the composite enable state - user toggle, usb suspend (via rgb_matrix_set_suspend_state), idle timeout. gate path runs independently of RGB_MATRIX_SLEEP.

quantum/rgblight/rgblight.c: drive set_power from
rgblight_init, the rgblight_enable variants, and rgblight_set (which also catches the rgblight_disable variants via the enable=false branch). rgblight_suspend and rgblight_wakeup compile unconditionally; they take the gate path when set_power is wired and otherwise fall back to the legacy RGBLIGHT_SLEEP code or early-return.

quantum/quantum.c: drop RGBLIGHT_SLEEP from the suspend and wakeup guards so gate-only boards receive the hooks. matches the existing rgb_matrix_set_suspend_state call pattern.

data/schemas/keyboard.jsonschema and
data/mappings/info_config.hjson:
schema entries and macro mappings for the two new fields.

docs/drivers/ws2812.md: new "VCC Enable Pin" section.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@github-actions github-actions Bot added core documentation dd Data Driven Changes labels May 16, 2026
@damex

damex commented May 16, 2026

Copy link
Copy Markdown
Author

i have decided to make it a list of pins that is driven together. please let me know if we should decouple that list to have separate named pins

@zvecr zvecr changed the base branch from master to develop May 16, 2026 08:34
opt in mechanism for boards that gate the WS2812 chain
vcc rail through one or more gpio.
ws2812 draw ~1ma each even when displaying black
long chains dominate standby drain on battery powered keyboards.
configured via ws2812.vcc_enable_pins (array)
and ws2812.vcc_active_low (bool) in keyboard.json.

drivers/led/ws2812.{c,h}: new ws2812_set_power(bool on),
compiled only when WS2812_VCC_ENABLE_PINS is defined.
polarity from WS2812_VCC_ACTIVE_LOW.
pins driven together in lockstep.
The driver dedupes consecutive identical calls and lazily flips
pins to output (write-then-set-output to avoid an active-low
glitch on the first call).

quantum/rgb_matrix/rgb_matrix_drivers.{c,h} and
quantum/rgblight/rgblight_drivers.{c,h}:
optional set_power vtable entry. ws2812 driver wires it only
when WS2812_VCC_ENABLE_PINS is defined; other drivers and
unconfigured ws2812 builds leave NULL. callers branch on
set_power != NULL so unconfigured boards keep their existing
render-zero-and-flush behavior.

quantum/rgb_matrix/rgb_matrix.c: drive set_power from
rgb_task_start with the composite enable state - user toggle,
usb suspend (via rgb_matrix_set_suspend_state), idle timeout.
gate path runs independently of RGB_MATRIX_SLEEP.

quantum/rgblight/rgblight.c: drive set_power from
rgblight_init, the rgblight_enable variants, and rgblight_set
(which also catches the rgblight_disable variants via the
enable=false branch). rgblight_suspend and rgblight_wakeup
compile unconditionally; they take the gate path when set_power
is wired and otherwise fall back to the legacy RGBLIGHT_SLEEP
code or early-return.

quantum/quantum.c: drop RGBLIGHT_SLEEP from the suspend
and wakeup guards so gate-only boards receive the hooks.
matches the existing rgb_matrix_set_suspend_state call pattern.

data/schemas/keyboard.jsonschema and
data/mappings/info_config.hjson:
schema entries and macro mappings for the two new fields.

docs/drivers/ws2812.md: new "VCC Enable Pin" section.

Signed-off-by: Roman Kuzmitskii <roman@damex.org>
@damex damex force-pushed the feat/ws2812-vcc-enable-pin branch from 16e58b9 to 636f2ee Compare May 16, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core dd Data Driven Changes documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant