Skip to content

fix(color): hold the HD 5-bit field fixed on a managed channel (P8 B1) - #4441

Merged
zackees merged 1 commit into
masterfrom
fix/b1-managed-hd-field-fixed
Sep 19, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/b1-managed-hd-field-fixed

Conversation

@zackees

@zackees zackees commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Problem

APA102-HD and SK9822-HD encode a colour triple from the RGB range plus a per-strip brightness from loadRGBScaleAndBrightness(), mapped to the 5-bit field.

On a managed channel the triple is the pipeline's drives, which already carry brightness as C4's flux scalar. ColorManagedPixelSource::loadRGBScaleAndBrightness() also forwarded the controller's brightness and colour scale, so the strip was dimmed twice:

  • a quarter of the light at half brightness;
  • a sixteenth at a quarter brightness.

This is the gap the #4042 comments trace (the HD path "does not do HD gamma at all", with brightness applied twice).

Fix

The managed source now reports full scale: colour 255/255/255, and brightness 255, which becomes field 31.

This is B1's conservative treatment, prescribed for SK9822 and for any chip without current-vs-chromaticity data. The 5-bit field is held fixed, and the pipeline is the only amplitude stage.

It needs no open decision. The APA102 joint code/field solve would use the field for low-light resolution, but it depends on B1's flicker floor (a maintainer decision), so it stays open. The header comment now says so.

Validation

  • RED → GREEN. With the controller at brightness 64:

    brightness colour scale
    before 64 (255, 192, 128)
    after 255 (255, 255, 255)

    A legacy-controller control in the same test still reports 64, so the check is about the managed source rather than a harness that never dims.

  • bash test color_managed_source passes, and so does --debug (ASAN/UBSAN).

  • bash test --cpp: 307/307 unit, 94/94 examples.

  • bash lint passes.

Part of #4042 (P8).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Fixed brightness handling for managed high-definition LED strips to prevent brightness from being applied twice.
    • Maintained consistent full-scale color and brightness output while preserving the intended overall dimming level.
  • Tests

    • Added coverage verifying correct brightness behavior for managed strips and retaining legacy controller behavior.

APA102-HD and SK9822-HD take a colour triple from the RGB range and a
per-strip brightness from loadRGBScaleAndBrightness(), mapped to the 5-bit
field. On a managed channel the triple is the pipeline's drives, which
already carry brightness as C4's flux scalar -- and ColorManagedPixelSource
forwarded the controller's brightness and colour scale as well, so the strip
was dimmed twice: a quarter of the light at half brightness, a sixteenth at
a quarter.

The managed source now reports full scale (colour 255/255/255, brightness
255 -> field 31). That is B1's conservative treatment for SK9822 and chips
without current-vs-chromaticity data: the field is held fixed and the
pipeline is the only amplitude stage. An APA102 joint code/field solve needs
B1's flicker floor and is left for that decision.

RED: at controller brightness 64 the managed source reported brightness 64
and scale (255,192,128); now 255 and (255,255,255), with a legacy-controller
control that still reports 64.

Part of #4042 (P8).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: FastLED/FastLED/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 98a001b0-2dd1-4e56-a360-99d29057f293

📥 Commits

Reviewing files that changed from the base of the PR and between 0eabde8 and 7883546.

📒 Files selected for processing (3)
  • src/fl/channels/color_managed_source.cpp.hpp
  • src/fl/channels/color_managed_source.h
  • tests/fl/channels/color_managed_source.cpp

Included review availability: Your plan provides up to 8 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The managed pixel source now reports full-scale colour and brightness values under FASTLED_HD_COLOR_MIXING. The controller path remains unchanged. Documentation and tests describe and verify the change.

Changes

Managed brightness scaling

Layer / File(s) Summary
Full-scale managed output
src/fl/channels/color_managed_source.cpp.hpp, src/fl/channels/color_managed_source.h, tests/fl/channels/color_managed_source.cpp
ColorManagedPixelSource::loadRGBScaleAndBrightness now writes 255 to all outputs. The documentation describes the fixed 5-bit field. The test verifies full-scale managed output and preserves the legacy controller result of 64.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 78835

Managed HD channels now avoid double dimming while legacy controller behavior remains covered; no actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: keeping the HD 5-bit field fixed on managed channels to prevent double dimming. It identifies the relevant color-management scope and P8 B1 c…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant