Skip to content

fix(color): managed non-HD APA102/SK9822 hold the field at 31 under global brightness (#4457) - #4464

Merged
zackees merged 2 commits into
masterfrom
fix/4457-managed-global-brightness
Sep 19, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/4457-managed-global-brightness

Conversation

@zackees

@zackees zackees commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

#4457: with FASTLED_USE_GLOBAL_BRIGHTNESS=1, encodeAPA102_AutoBrightness /
encodeSK9822_AutoBrightness derive one strip-wide 5-bit field from the
first pixel's peak and rescale only that pixel, dimming the rest by
field/31. On a colour-managed channel that is a second shaping stage on
drives the pipeline already solved -- the one exception the P8 encoder
table named against section 6.

Managed half: ColorPipelineHooks::encodeManagedSpi now owns non-HD
APA102/DOTSTAR/HD107/SK9822 and always encodes with field 31 (B1's
conservative treatment), independent of the option. With the option off
that is exactly the encoder's own path, so default output is unchanged;
linked only when a profile is bound.

Legacy half: left as it is. It is long-standing behaviour of an opt-in
build flag, and changing it would change the output of every sketch that
sets it. Recorded in the encoder table.

Test: the hook, called directly, claims each of the four chips and emits
field 31 with the pipeline's codes (fails if it declines one -- a
Channel-level test could not tell the paths apart with the option off).
Builds with -DFASTLED_USE_GLOBAL_BRIGHTNESS=1 (esp32s3 ColorProfile).
307/307 unit, 95/95 examples; uno Blink unchanged.

Closes #4457.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved managed SPI output for APA102, SK9822, DOTSTAR, and HD107 LEDs by consistently encoding the brightness field at its maximum value.
    • Prevented an additional brightness adjustment from being applied to managed channels, improving color and brightness accuracy.
  • Documentation

    • Updated the color pipeline documentation to reflect managed-channel encoding behavior and clarify the distinction from legacy operation.

…lobal brightness (#4457)

#4457: with FASTLED_USE_GLOBAL_BRIGHTNESS=1, encodeAPA102_AutoBrightness /
encodeSK9822_AutoBrightness derive one strip-wide 5-bit field from the
first pixel's peak and rescale only that pixel, dimming the rest by
field/31. On a colour-managed channel that is a second shaping stage on
drives the pipeline already solved -- the one exception the P8 encoder
table named against section 6.

Managed half: ColorPipelineHooks::encodeManagedSpi now owns non-HD
APA102/DOTSTAR/HD107/SK9822 and always encodes with field 31 (B1's
conservative treatment), independent of the option. With the option off
that is exactly the encoder's own path, so default output is unchanged;
linked only when a profile is bound.

Legacy half: left as it is. It is long-standing behaviour of an opt-in
build flag, and changing it would change the output of every sketch that
sets it. Recorded in the encoder table.

Test: the hook, called directly, claims each of the four chips and emits
field 31 with the pipeline's codes (fails if it declines one -- a
Channel-level test could not tell the paths apart with the option off).
Builds with -DFASTLED_USE_GLOBAL_BRIGHTNESS=1 (esp32s3 ColorProfile).
307/307 unit, 95/95 examples; uno Blink unchanged.

Closes #4457.

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: 8daf82fd-8c10-4fa7-a7a2-d2b4b885135b

📥 Commits

Reviewing files that changed from the base of the PR and between 412e2c3 and 6bc9b4e.

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

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


📝 Walkthrough

Walkthrough

Managed APA102, DOTSTAR, HD107, and SK9822 encoding now uses encodeManagedSpi with the field fixed at 31. Tests verify the emitted frames. Documentation distinguishes this behavior from the unchanged legacy path.

Changes

Managed SPI field handling

Layer / File(s) Summary
Fixed managed SPI field and validation
src/fl/channels/pipeline_binding.cpp.hpp, tests/fl/channels/color_managed_source.cpp, docs/color-pipeline-contracts.md
Managed SPI encoding uses field 31 for APA102, DOTSTAR, HD107, and SK9822. Tests verify the start frames and quantized color bytes. Documentation records the managed behavior and the unchanged legacy behavior.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

🚥 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 2 functions across 2 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 describes the managed-channel field-31 fix for APA102/SK9822 under global brightness. It omits DOTSTAR and HD107, but it accurately identifies the primary issue addressed by the chan…
Linked Issues check ✅ Passed Issue #4457 requires a fixed 5-bit field on managed channels and unchanged legacy behavior. encodeColorPipelineManagedSpi routes APA102, DOTSTAR, HD107, and SK9822 to writeFiveBitWide(..., 31) bef…
Out of Scope Changes check ✅ Passed The source change, direct hook test, and documentation update support Issue #4457. DOTSTAR and HD107 use the same managed five-bit encoding row and are covered by the same field fix. No unrelated chan…
  • 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.

…r instantiation

Calling encodeAPA102/encodeSK9822 from the hook made the compiler outline
them (+135 B each) in place of the copies inlined into writeAPA102 /
writeSK9822 (-114 B each): +55 B on ESP32-S3 Blink, which binds no
profile. The hook now uses writeFiveBitWide pinned at field 31, which it
already links for the HD chips: same framing, one quantization from the
16-bit drive, and ESP32-S3 Blink byte-identical to master.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.

APA102/SK9822 FASTLED_USE_GLOBAL_BRIGHTNESS: field from pixel 0 dims the rest of the strip; unreviewed on managed channels

1 participant