Skip to content

Add led serial command for RGB LED control - #2772

Open
loratrak wants to merge 1 commit into
BruceDevices:devfrom
loratrak:feat/led-serial-command
Open

Add led serial command for RGB LED control#2772
loratrak wants to merge 1 commit into
BruceDevices:devfrom
loratrak:feat/led-serial-command

Conversation

@loratrak

@loratrak loratrak commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Problem

The led command is listed in the CLI help output but was never registered with the CLI, so typing it in the serial terminal returns ERROR: Command not found. The help entry also describes it as changing the UI main color, which is what the existing screen color rgb / screen color hex commands already do.

Change

Register a real led composite command that drives the physical RGB LED:

led r|g|b <0-255>       change a single channel, keeping the other two
led rgb <r> <g> <b>     set the full color
led hex <RRGGBB>        set the full color
led brightness <0-100>  aliases: br, bright
led effect <0-9>        0 selects the solid color
led off

The callbacks write through bruceConfig and call ledSetup() instead of touching leds[] directly. When an effect is active, its task reads the color, effect, speed and direction straight from bruceConfig (led_control.cpp), so a direct write would be overwritten on the next frame. As a side effect the change persists across reboots, matching the behaviour of the LED settings menu.

The whole translation unit is guarded by HAS_RGB_LED: led_control.h only declares its API under that define, and PlatformIO compiles every source file regardless of the target board.

The help text is fixed as well. The UI section now documents the real screen commands, and a new "RGB LED Commands" section is printed only on boards that actually have an RGB LED.

Testing

Built successfully for m5stack-cardputer and Lilygo-t-embed-cc1101 (has HAS_RGB_LED) and Marauder-Mini (does not), covering both sides of the guard. Tested only on Lilygo-t-embed-cc1101

🤖 Generated with Claude Code and double checked by me ;-)

The `led` command was listed in `help` but never registered with the CLI,
so typing it in the terminal returned "Command not found". Its help entry
also described it as changing the UI main color, which is what the existing
`screen color` command does.

Register a real `led` composite command that drives the physical RGB LED:

  led r|g|b <0-255>       change a single channel, keeping the other two
  led rgb <r> <g> <b>     set the full color
  led hex <RRGGBB>        set the full color
  led brightness <0-100>  aliases: br, bright
  led effect <0-9>        0 selects the solid color
  led off

The callbacks write through bruceConfig and call ledSetup() instead of
touching leds[] directly. When an effect is active its task reads the color,
effect, speed and direction straight from bruceConfig, so a direct write
would be overwritten on the next frame. As a side effect the change persists
across reboots, matching the behaviour of the LED settings menu.

The whole translation unit is guarded by HAS_RGB_LED: led_control.h only
declares its API under that define, and PlatformIO compiles every source
file regardless of the target board.

Also fix the help text. The UI section now documents the real `screen`
commands, and a new "RGB LED Commands" section is printed only on boards
that actually have an RGB LED.

Built for m5stack-cardputer (HAS_RGB_LED) and Marauder-Mini (without it).
@pr3y
pr3y changed the base branch from main to dev August 8, 2026 15:24
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.

1 participant