Skip to content

Harden LED configuration and color packing#94

Open
mjc wants to merge 2 commits into
lukash:mainfrom
mjc:refloat-fix-led-driver-encoding
Open

Harden LED configuration and color packing#94
mjc wants to merge 2 commits into
lukash:mainfrom
mjc:refloat-fix-led-driver-encoding

Conversation

@mjc

@mjc mjc commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Validate LED strip color order before allocating DMA storage and report which strip is invalid.

The paint path also rejects unexpected encodings, and channel values are widened before bit packing. Valid GRB, GRBW, RGB, and WRGB output is unchanged.

Copilot AI review requested due to automatic review settings July 15, 2026 17:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the LED driver’s handling of LED strip color order/encoding by validating configuration earlier and making color packing/shifting behavior well-defined for 32-bit output values.

Changes:

  • Reject invalid LedColorOrder values during led_driver_setup() before calculating/allocating the DMA bitbuffer, with an error that identifies the offending strip index.
  • Make color channel bit packing explicitly use uint32_t widening before shifts to avoid undefined behavior on 32-bit targets.
  • Reject unexpected color_order encodings in the paint path (added a default case in the switch).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/led_driver.c Outdated
Comment thread src/led_driver.c
Comment thread src/led_driver.c Outdated
@mjc
mjc force-pushed the refloat-fix-led-driver-encoding branch from a235ded to 8ae1c33 Compare July 20, 2026 18:42
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.

3 participants