Skip to content

feat(rgbww): 5-channel RGB+WW pipeline via Channels API (#2558 Phases A-F) - #2560

Merged
zackees merged 1 commit into
masterfrom
feat/rgbww-phase-abc
May 30, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/rgbww-phase-abc

Conversation

@zackees

@zackees zackees commented May 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Lands all six phases of #2558 in a single PR: 5-channel RGB + warm-W + cool-W (RGBWW / RGBCCT) end-to-end through the Channels API.

Builds directly on top of the colorimetric math shipped in #2552 / #2554 — solve_rgbcct was already in-tree as a header helper; this PR is the driver-layer plumbing that finally consumes it.

Phase summary

Phase Scope
A — Types + variant migration New Rgbww config, RGBWW_MODE, EOrderWW, RGBWWPixel, BYTES_PER_PIXEL_RGBWW = 5. ChannelOptions.mRgbw → mWhiteCfg: fl::variant<fl::Empty, Rgbw, Rgbww>. Backward-compat setRgbw/getRgbw.
B — Dispatch shells rgb_2_rgbww_function typedef, rgb_2_rgbww() dispatcher, mode stubs (warn-once + zero out when FASTLED_RGBWW undefined).
C — Encoder pipeline PixelControllerVtable::loadAndScaleRGBWW, ScaledPixelIteratorRGBWW, rgbww_partial_reorder, PixelController::loadAndScaleRGBWW, writeWS2812 dispatches RGBWW > RGBW > RGB, encodeWS2812_RGBWW.
D — Wire solve_rgbcct kRgbwwDefaultProfile (hardcoded SK6812-style + Planckian 2700/6500K xy), get/set profile API. Real colorimetric dispatch when both FASTLED_RGBWW and FASTLED_RGBW_COLORIMETRIC are defined; clear warn-once when only one is.
E — First chipset + tests WS2812/SK6812-RGBWW works end-to-end. New tests/fl/gfx/rgbww.cpp validates dispatch + all four EOrderWW orderings + user-function callback + profile get/set. AutoResearch hardware harness deferred (no RGBWW strip to validate against).
F — Power model PowerModelRGBWW::toRGB() no longer drops W/WW power — distributes (white_mW + warm_white_mW) / 3 evenly across R/G/B so the brightness limiter doesn't under-budget.

Scoping

Channels API only. Legacy CPixelLEDController<RGB> subclasses unchanged; existing 4-channel RGBW behavior byte-for-byte preserved when ChannelOptions holds the Rgbw alternative.

Compile gates

Macro Effect
FASTLED_RGBWW (default OFF) Pulls in the RGBWW encoder pipeline. Without it: stub paths warn-once + emit zeros.
FASTLED_RGBW_COLORIMETRIC (default OFF) Required additionally for the real solve_rgbcct dispatch. With only FASTLED_RGBWW: clearer warn-once explaining the dependency.
FASTLED_SUPPRESS_RGBWW_FALLBACK_WARNING Silences the stub-path warn-once for portability builds.

Usage

// platformio.ini build_flags: -DFASTLED_RGBWW=1 -DFASTLED_RGBW_COLORIMETRIC=1

fl::ChannelOptions opts;
opts.mWhiteCfg = fl::Rgbww(2700, 6500, fl::RGBWW_MODE::kRGBWWColorimetric);
fl::ChannelConfig cfg(pin, timing, leds, GRB, opts);
auto ch = FastLED.add(cfg);
// ChannelData now emits 5 bytes/pixel through the same clockless driver path.

Test plan

  • tests/fl/gfx/rgbww.cpp — Rgbww defaults, all EOrderWW orderings, dispatch (invalid → zeros; colorimetric link-safe; user-function callback round-trip; profile get/set).
  • tests/power_mgt.cpp — updated for new toRGB() contract.
  • tests/fastled_core.cpp — variant migration; existing ChannelOptions API exercised via applyConfig.
  • Full host C++ test suite passes (305 unit tests + new RGBWW tests).
  • Lint passes.
  • Manual: configure a real SK6812-RGBWW strip with -DFASTLED_RGBWW=1 -DFASTLED_RGBW_COLORIMETRIC=1 and validate output bytes via logic analyzer / colorimeter — deferred to a follow-up since I have no RGBWW hardware here.

Closes #2558.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Native 5-channel RGBWW pipeline: RGB + warm + cool white, selectable conversion modes, byte-ordering options, and controller APIs to set/clear white-channel configs.
    • Encoders and pixel pipeline now emit 5-byte RGBWW frames; some legacy encoders will warn and fall back to RGB when WW is unsupported.
  • Power

    • Power model now folds white-channel power into the RGB budget instead of discarding it.
  • Examples

    • New Arduino RGBWW example demonstrating setup and warm↔cool animation.
  • Tests

    • Added unit tests covering RGBWW conversion, ordering, dispatch, and power-model behavior.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 30, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds optional 5-channel RGBWW support: new RGBWW types and ChannelOptions variant, rgb→rgbww conversion paths (colorimetric, boosted, user-callback), encoder/pixel-iterator plumbing for 5-byte pixels, Channel wiring to select white-mode, power-model folding for white power, tests, and an example.

Changes

RGBWW 5-channel Channels API implementation

Layer / File(s) Summary
RGBWW type system and channel configuration
src/fl/gfx/rgbww.h, src/fl/gfx/rgbww_pixel.h, src/fl/channels/options.h, src/fl/channels/cled_controller.h
Adds Rgbww, EOrderWW, RGBWW_MODE, RGBWWPixel; ChannelOptions::mWhiteCfg becomes variant<Empty,Rgbw,Rgbww>; adds setRgbww/clearWhiteChannel/getRgbww and compatibility accessors.
RGB→RGBWW conversion and dispatch layer
src/fl/gfx/rgbww.cpp.hpp
Implements rgb_2_rgbww dispatcher, colorimetric and boosted solvers, user-function dispatch, default/active profile API, and rgbww_partial_reorder.
RGBW colorimetric LUT changes
src/fl/gfx/rgbw.cpp.hpp, src/fl/gfx/rgbw.h
LUT state and enable/disable functions are compiled under FASTLED_RGBW_COLORIMETRIC and runtime-gated by the LUT enabled flag; documentation updated accordingly.
Pixel iterator and encoder 5-channel support
src/fl/chipsets/encoders/encoder_constants.h, src/fl/chipsets/encoders/pixel_iterator.h, src/fl/chipsets/encoders/pixel_iterator_adapters.h, src/fl/chipsets/encoders/ws2812.h, src/pixel_controller.h
Adds BYTES_PER_PIXEL_RGBWW=5; extends PixelIterator vtable and state for RGBWW; adds ScaledPixelIteratorRGBWW and makeScaledPixelRangeRGBWW; adds encodeWS2812_RGBWW; implements PixelController::loadAndScaleRGBWW.
Channel and PixelIteratorAny RGBWW wiring
src/fl/gfx/pixel_iterator_any.h, src/fl/channels/channel.cpp.hpp, src/fl/gfx/_build.cpp.hpp
PixelIteratorAny and visitor accept/store Rgbww; ReorderingPixelIteratorAny constructed with both rgbw and rgbww; applyWhiteCfg() helper routes mWhiteCfg into setRgbw/setRgbww/clearWhiteChannel; showPixels() constructs iterator with both white settings; unity build includes rgbww.cpp.hpp.
Power management for RGBWW
src/power_mgt.h
PowerModelRGBWW::toRGB() folds white-channel mW into RGB channels evenly instead of discarding it.
Tests and example
tests/fl/gfx/rgbww.cpp, tests/fastled_core.cpp, tests/power_mgt.cpp, examples/RGBWW/RGBWW.ino
Adds unit tests for Rgbww, rgbww_partial_reorder, rgb_2_rgbww modes and profile API; updates Channel and power-model tests; adds an Arduino example demonstrating RGBWW usage.

Sequence Diagram

sequenceDiagram
  participant App as Application
  participant Channel as Channel API
  participant Iterator as PixelIteratorAny
  participant Converter as rgb_2_rgbww
  participant Encoder as WS2812 Encoder
  participant Output as LED Wire
  App->>Channel: configure with Rgbww (warm_cct, cool_cct, mode)
  Channel->>Channel: applyWhiteCfg() route by mWhiteCfg
  Channel->>Iterator: PixelIteratorAny (rgbw, rgbww)
  Channel->>Iterator: showPixels() -> writeWS2812 dispatch RGBWW first
  Iterator->>Encoder: loadAndScaleRGBWW (scaled r,g,b)
  Encoder->>Converter: rgb_2_rgbww (mode, chromaticity)
  Converter->>Encoder: 5 output bytes (r,g,b,ww,wc)
  Encoder->>Output: stream wire-order 5-byte pixels
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

  • #2545: Main RGBWW feature tracking; this PR implements the Channels API RGBWW pipeline and related work.

Possibly related PRs

  • FastLED/FastLED#2441: Modifies Channel::showPixels() driver-selection logic; overlaps with this PR's show-path changes.
  • FastLED/FastLED#2468: Also touches UCS7604 encoding selection/behavior; related to UCS7604 RGBWW handling changes.

Poem

🐰 I hopped through bytes with five bright lights,
Warm and cool tucked in cozy nights,
A rabbit-coded shuffle, neat and true,
Now strips can glow in dual-hue,
Hop, blink, blend — a tiny LED revue.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.28% which is insufficient. The required threshold is 80.00%. 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 PR title 'feat(rgbww): 5-channel RGB+WW pipeline via Channels API (#2558 Phases A-F)' clearly and specifically summarizes the main change—implementing a 5-channel RGBWW pipeline via the Channels API across all six phases.
Linked Issues check ✅ Passed The PR implements all six phases (A–F) from issue #2558, covering types/variants, dispatch shells, encoder pipeline, colorimetric wiring, chipset updates, and power modeling, with comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #2558 scope: Channels API only, new RGBWW types/configs, encoder extensions, colorimetric dispatch, and power model updates; legacy addLeds<> and CPixelLEDController remain unchanged.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rgbww-phase-abc

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 and usage tips.

@zackees
zackees force-pushed the feat/rgbww-phase-abc branch from c059634 to 8b4c286 Compare May 30, 2026 04:18

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/fl/channels/channel.cpp.hpp (1)

195-199: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Persist ChannelOptions into mSettings before encoding.

These paths update the controller, but showPixels() reads white config and gamma from mSettings, and this file never assigns mSettings = options / config.options. As written, RGBW/RGBWW/gamma can encode with stale defaults even after construction or applyConfig().

Suggested fix
 Channel::Channel(const ChipsetVariant& chipset, fl::span<CRGB> leds,
                  EOrder rgbOrder, const ChannelOptions& options)
     : CPixelLEDController<RGB>(RegistrationMode::DeferRegister)  // Defer registration until FastLED.add()
     , mChipset(chipset)
     , mRgbOrder(rgbOrder)
     , mDriver()  // Empty weak_ptr - late binding on first showPixels()
     , mBus(options.mBus)  // Bus selection (`#2459`)
     , mId(nextId())
     , mName(makeName(mId)) {
+    mSettings = options;
     // NOTE: Do NOT call fl::pinMode() here. The pin may already be
     // configured for SPI output by a persistent driver (ChannelEngineSpi).
     // Calling pinMode(InputPulldown) would disconnect the SPI MOSI from the
     // GPIO matrix, causing subsequent transmissions to produce no output.
     // The driver will configure the pin when it first uses it.
@@
 Channel::Channel(int pin, const ChipsetTimingConfig& timing, fl::span<CRGB> leds,
                  EOrder rgbOrder, const ChannelOptions& options)
     : CPixelLEDController<RGB>(RegistrationMode::DeferRegister)  // Defer registration until FastLED.add()
     , mChipset(ClocklessChipset(pin, timing))  // Convert to variant
     , mRgbOrder(rgbOrder)
     , mDriver()  // Empty weak_ptr - late binding on first showPixels()
     , mBus(options.mBus)  // Bus selection (`#2459`)
     , mId(nextId())
     , mName(makeName(mId)) {
+    mSettings = options;
     // NOTE: Do NOT call fl::pinMode() here — see comment in the
     // Channel(ChipsetVariant, span, EOrder, ChannelOptions) constructor.
@@
 void Channel::applyConfig(const ChannelConfig& config) {
+    mSettings = config.options;
     mRgbOrder = config.rgb_order;
     if (config.mName.has_value()) {
         mName = config.mName.value();
     }

Also applies to: 225-245, 383-389

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fl/channels/channel.cpp.hpp` around lines 195 - 199, Persist
ChannelOptions into mSettings before applying controller updates and encoding:
assign mSettings = options (or mSettings.options = config.options if relevant)
at the start of the code paths that call setCorrection, setTemperature,
setDither, and applyWhiteCfg so that showPixels() and gamma/white-config reads
use the updated values; do the same persistent assignment in the other similar
blocks referenced (the blocks around applyConfig and the later encoding paths)
to ensure RGBW/RGBWW/gamma are not using stale defaults.
🧹 Nitpick comments (1)
src/fl/gfx/rgbww.h (1)

107-167: 🏗️ Heavy lift

Consider safer RGBWW output APIs (span/result) instead of five raw output pointers
The C++ standards prefer passing/returning by fl::span for parameters, but RGBWW currently mirrors the established RGBW pattern by exposing five independent fl::u8* outputs in the public dispatch and user-function signatures. To reduce miscall risk without large churn, add an overload that returns a small RGBWW result struct or accepts fl::span<fl::u8> (size 5) for outputs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fl/gfx/rgbww.h` around lines 107 - 167, The public RGBWW APIs expose five
raw output pointers (rgb_2_rgbww_function, rgb_2_rgbww_user_function,
rgb_2_rgbww_colorimetric, rgb_2_rgbww_colorimetric_boosted,
rgbww_partial_reorder) which is error-prone; add safe overloads that either (a)
accept a fl::span<fl::u8> of size 5 for outputs or (b) return a small RGBWW
result struct (e.g. struct RgbwwOut { fl::u8 v[5]; }); while keeping the
existing pointer-based signatures for ABI compatibility. Implement new overload
signatures (e.g. rgb_2_rgbww_user_function(const Rgbww&,..., fl::span<fl::u8>
out) and rgbww_partial_reorder(EOrderWW,..., fl::span<fl::u8> out)) and provide
thin adapter implementations that call the existing pointer-based functions (or
vice versa) so callers can opt into the safer API without breaking existing
code; expose matching setter overloads for set_rgb_2_rgbww_function if you want
user-installable span-typed callbacks. Ensure span implementations validate
size==5 and document fallback behavior to preserve current semantics.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/fl/channels/channel.cpp.hpp`:
- Around line 383-389: showPixels() currently forwards mSettings.rgbww() into
ReorderingPixelIteratorAny for all clockless encoders but writeUCS7604() only
checks get_rgbw().active(), so an RGBWW-configured UCS7604 channel will drop the
white channels; update the UCS7604 path in writeUCS7604() (and any related
encoder dispatch) to either check the rgbww() active flag (e.g.,
get_rgbww().active() or the ChannelOptions::mWhiteCfg alternative) before using
white-channel data or gate passing mSettings.rgbww() from showPixels() for
non-RGBWW clockless encoders so that ReorderingPixelIteratorAny only receives
rgbww for encoders that actually support RGBWW (ensure the change references
ReorderingPixelIteratorAny, mSettings.rgbww(), showPixels(), and
writeUCS7604()).

In `@src/fl/channels/cled_controller.h`:
- Around line 75-97: setRgbw and setRgbww currently assign the invalid sentinel
(e.g. RgbwInvalid::value() / RgbwwInvalid::value()) into mSettings.mWhiteCfg
which preserves a white-channel alternative instead of disabling it; change both
CLEDController::setRgbw and CLEDController::setRgbww to detect the invalid
sentinel and call mSettings.mWhiteCfg.reset() (clearing the variant) when that
sentinel is passed, otherwise assign the provided Rgbw/Rgbww value as before so
applyWhiteCfg still dispatches to the empty alternative when the mode is meant
to be disabled.

In `@src/fl/channels/options.h`:
- Around line 66-69: The predicates isRgbw() and isRgbww() should not just test
the stored variant type via mWhiteCfg.is<Rgbw>()/is<Rgbww>() because legacy
sentinel types like RgbwInvalid/RgbwwInvalid still make those tests true;
instead inspect the active variant and return its effective enabled state by
fetching the contained object and calling its value() (or using
mWhiteCfg.visit/match/get_if to access the Rgbw/Rgbww instance and return
instance.value()); update isRgbw() and isRgbww() to return mWhiteCfg.is<Rgbw>()
&& get<Rgbw>(.../visit).value() (and analogous for Rgbww) so they reflect active
configs rather than just stored variant types.

In `@src/fl/gfx/pixel_iterator_any.h`:
- Around line 38-43: The templated PixelIteratorAny constructor creates a
normalized PixelController<RGB> named rgbController but still calls
init(controller, newOrder), which fails because init expects a
PixelController<RGB>&; update the constructor to call init(rgbController,
newOrder) so the normalized controller is passed in (keep the rest of the
signature PixelIteratorAny(PIXEL_CONTROLLER &controller, EOrder newOrder, Rgbw
rgbw, Rgbww rgbww = RgbwwInvalid::value()) and preserve setting mRgbw/mRgbww and
construction of rgbController).

In `@src/fl/gfx/rgbww.cpp.hpp`:
- Around line 186-195: When cfg.profile is null you currently always use
get_rgbww_colorimetric_profile() unchanged; instead, when cfg.profile == nullptr
create a local copy of the returned profile, derive warm/cool white points from
cfg.warm_cct and cfg.cool_cct (if they are set) and apply those values to the
copied profile before calling compute_eta_from_input(...) and
colorimetric_detail::solve_rgbcct(...); do the same change for the second
occurrence noted (lines ~218-229) so both code paths solve against the adjusted
profile rather than the unmodified default.

In `@src/power_mgt.h`:
- Around line 134-142: The toRGB() conversion can overflow when computing red_mW
+ (white_mW + warm_white_mW) / 3 causing static_cast<fl::u8> to wrap; clamp each
computed channel value to the 0–255 range before casting and constructing
PowerModelRGB. Update the toRGB() implementation to compute each channel as an
integer, apply std::min/std::clamp (or an explicit min with 255) to cap the
value at 255 (and 0 if needed), then static_cast to fl::u8 for red/green/blue
while leaving dark_mW and exponent unchanged; refer to toRGB(), red_mW,
green_mW, blue_mW, white_mW, warm_white_mW, and PowerModelRGB to locate and fix
the code.

---

Outside diff comments:
In `@src/fl/channels/channel.cpp.hpp`:
- Around line 195-199: Persist ChannelOptions into mSettings before applying
controller updates and encoding: assign mSettings = options (or
mSettings.options = config.options if relevant) at the start of the code paths
that call setCorrection, setTemperature, setDither, and applyWhiteCfg so that
showPixels() and gamma/white-config reads use the updated values; do the same
persistent assignment in the other similar blocks referenced (the blocks around
applyConfig and the later encoding paths) to ensure RGBW/RGBWW/gamma are not
using stale defaults.

---

Nitpick comments:
In `@src/fl/gfx/rgbww.h`:
- Around line 107-167: The public RGBWW APIs expose five raw output pointers
(rgb_2_rgbww_function, rgb_2_rgbww_user_function, rgb_2_rgbww_colorimetric,
rgb_2_rgbww_colorimetric_boosted, rgbww_partial_reorder) which is error-prone;
add safe overloads that either (a) accept a fl::span<fl::u8> of size 5 for
outputs or (b) return a small RGBWW result struct (e.g. struct RgbwwOut { fl::u8
v[5]; }); while keeping the existing pointer-based signatures for ABI
compatibility. Implement new overload signatures (e.g.
rgb_2_rgbww_user_function(const Rgbww&,..., fl::span<fl::u8> out) and
rgbww_partial_reorder(EOrderWW,..., fl::span<fl::u8> out)) and provide thin
adapter implementations that call the existing pointer-based functions (or vice
versa) so callers can opt into the safer API without breaking existing code;
expose matching setter overloads for set_rgb_2_rgbww_function if you want
user-installable span-typed callbacks. Ensure span implementations validate
size==5 and document fallback behavior to preserve current semantics.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b4fea495-f5ea-41b6-a62d-fa03d8410c7c

📥 Commits

Reviewing files that changed from the base of the PR and between 84777a8 and c059634.

📒 Files selected for processing (17)
  • src/fl/channels/channel.cpp.hpp
  • src/fl/channels/cled_controller.h
  • src/fl/channels/options.h
  • src/fl/chipsets/encoders/encoder_constants.h
  • src/fl/chipsets/encoders/pixel_iterator.h
  • src/fl/chipsets/encoders/pixel_iterator_adapters.h
  • src/fl/chipsets/encoders/ws2812.h
  • src/fl/gfx/_build.cpp.hpp
  • src/fl/gfx/pixel_iterator_any.h
  • src/fl/gfx/rgbww.cpp.hpp
  • src/fl/gfx/rgbww.h
  • src/fl/gfx/rgbww_pixel.h
  • src/pixel_controller.h
  • src/power_mgt.h
  • tests/fastled_core.cpp
  • tests/fl/gfx/rgbww.cpp
  • tests/power_mgt.cpp

Comment on lines 383 to +389
// Build pixel iterator with optional addressing transformation
ReorderingPixelIteratorAny iterator(pixels, mScreenMap.getXYMap(), mRgbOrder, mSettings.mRgbw, mName);
// (#2558) Pass both Rgbw and Rgbww from the channel options; the iterator
// carries both, and the encoder dispatch below picks the right path based
// on which variant alternative ChannelOptions::mWhiteCfg holds.
ReorderingPixelIteratorAny iterator(pixels, mScreenMap.getXYMap(), mRgbOrder,
mSettings.rgbw(), mSettings.rgbww(),
mName);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Reject or gate Rgbww on non-RGBWW clockless encoders.

showPixels() now forwards rgbww() into every clockless path, but writeUCS7604() in this file still only checks get_rgbw().active(). A UCS7604 channel configured as RGBWW will silently encode as plain RGB and drop both white channels.

Suggested fix
     if (mChipset.is<ClocklessChipset>()) {
         // Clockless chipsets: dispatch based on encoder type
         const ClocklessChipset* clockless = mChipset.ptr<ClocklessChipset>();
         switch (clockless->encoder) {
             case ClocklessEncoder::CLOCKLESS_ENCODER_WS2812:
                 pixelIterator.writeWS2812(&data);
                 break;
             case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_8BIT:
             case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_16BIT:
             case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_16BIT_1600:
+                if (pixelIterator.get_rgbww().active()) {
+                    FL_ERROR("Channel '" << mName
+                             << "': RGBWW is not supported by the UCS7604 encoder path");
+                    return;
+                }
                 writeUCS7604(&data, pixelIterator, clockless->encoder,
                              mSettings, mRgbOrder);
                 break;
         }
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fl/channels/channel.cpp.hpp` around lines 383 - 389, showPixels()
currently forwards mSettings.rgbww() into ReorderingPixelIteratorAny for all
clockless encoders but writeUCS7604() only checks get_rgbw().active(), so an
RGBWW-configured UCS7604 channel will drop the white channels; update the
UCS7604 path in writeUCS7604() (and any related encoder dispatch) to either
check the rgbww() active flag (e.g., get_rgbww().active() or the
ChannelOptions::mWhiteCfg alternative) before using white-channel data or gate
passing mSettings.rgbww() from showPixels() for non-RGBWW clockless encoders so
that ReorderingPixelIteratorAny only receives rgbww for encoders that actually
support RGBWW (ensure the change references ReorderingPixelIteratorAny,
mSettings.rgbww(), showPixels(), and writeUCS7604()).

Comment thread src/fl/channels/cled_controller.h Resolved
Comment thread src/fl/channels/options.h Resolved
Comment thread src/fl/gfx/pixel_iterator_any.h Resolved
Comment thread src/fl/gfx/rgbww.cpp.hpp Resolved
Comment thread src/power_mgt.h Resolved
@zackees
zackees force-pushed the feat/rgbww-phase-abc branch 2 times, most recently from fd88956 to 3089458 Compare May 30, 2026 05:25

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/power_mgt.h (1)

134-142: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Still unfixed: overflow wraps instead of clamping.

This is the same issue previously flagged. When red_mW + (white_mW + warm_white_mW) / 3 exceeds 255, the static_cast<fl::u8> wraps (e.g., 425 → 169), severely under-budgeting power on high-draw RGBWW configurations. The suggested fix in the prior review (computing as fl::u16, clamping to 255, then casting) remains the correct approach.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/power_mgt.h` around lines 134 - 142, The toRGB() conversion in
PowerModelRGB currently computes channel sums and directly static_casts to
fl::u8, which wraps on overflow; change the intermediate math to use a wider
type (e.g., fl::u16) for expressions like red_mW + (white_mW + warm_white_mW) /
3, clamp the resulting value to 255 (max for fl::u8), then static_cast to fl::u8
before constructing PowerModelRGB; update the three channel expressions (red,
green, blue) in toRGB() to use this widen-and-clamp pattern so values never
wrap.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pixel_controller.h`:
- Around line 637-646: The AVR branch currently silently zeroes both white
channels (in the FL_IS_AVR block that calls rgbww_partial_reorder with 0,0),
which makes RGBWW strips appear as RGB; instead, detect when the configured
strip is RGBWW (using rgbww.w_placement or the pixel format) and either (a)
explicitly reject/abort with a clear error/return path for rgbww pixels on AVR,
or (b) emit a visible warning/log message and fall back to a safe behavior that
preserves white-channel input (e.g., pass through the original white values or a
clear dither/fallback) rather than writing 0,0; modify the FL_IS_AVR branch
around loadAndScale0/loadAndScale2 and the call to rgbww_partial_reorder to
implement one of these two options and ensure the code path uses a logging API
or an error return so the failure is not silent.

---

Duplicate comments:
In `@src/power_mgt.h`:
- Around line 134-142: The toRGB() conversion in PowerModelRGB currently
computes channel sums and directly static_casts to fl::u8, which wraps on
overflow; change the intermediate math to use a wider type (e.g., fl::u16) for
expressions like red_mW + (white_mW + warm_white_mW) / 3, clamp the resulting
value to 255 (max for fl::u8), then static_cast to fl::u8 before constructing
PowerModelRGB; update the three channel expressions (red, green, blue) in
toRGB() to use this widen-and-clamp pattern so values never wrap.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 31377c13-1659-4634-a9d9-9c4b7d880ecd

📥 Commits

Reviewing files that changed from the base of the PR and between fd88956 and 3089458.

📒 Files selected for processing (20)
  • examples/RGBWW/RGBWW.ino
  • src/fl/channels/channel.cpp.hpp
  • src/fl/channels/cled_controller.h
  • src/fl/channels/options.h
  • src/fl/chipsets/encoders/encoder_constants.h
  • src/fl/chipsets/encoders/pixel_iterator.h
  • src/fl/chipsets/encoders/pixel_iterator_adapters.h
  • src/fl/chipsets/encoders/ws2812.h
  • src/fl/gfx/_build.cpp.hpp
  • src/fl/gfx/pixel_iterator_any.h
  • src/fl/gfx/rgbw.cpp.hpp
  • src/fl/gfx/rgbw.h
  • src/fl/gfx/rgbww.cpp.hpp
  • src/fl/gfx/rgbww.h
  • src/fl/gfx/rgbww_pixel.h
  • src/pixel_controller.h
  • src/power_mgt.h
  • tests/fastled_core.cpp
  • tests/fl/gfx/rgbww.cpp
  • tests/power_mgt.cpp
✅ Files skipped from review due to trivial changes (2)
  • src/fl/gfx/rgbw.h
  • src/fl/gfx/_build.cpp.hpp
🚧 Files skipped from review as they are similar to previous changes (13)
  • src/fl/gfx/rgbww_pixel.h
  • tests/power_mgt.cpp
  • tests/fastled_core.cpp
  • examples/RGBWW/RGBWW.ino
  • src/fl/chipsets/encoders/pixel_iterator_adapters.h
  • src/fl/gfx/pixel_iterator_any.h
  • src/fl/chipsets/encoders/ws2812.h
  • src/fl/channels/options.h
  • src/fl/channels/cled_controller.h
  • src/fl/channels/channel.cpp.hpp
  • src/fl/gfx/rgbww.cpp.hpp
  • src/fl/gfx/rgbww.h
  • src/fl/chipsets/encoders/pixel_iterator.h

Comment thread src/pixel_controller.h
Comment on lines +637 to +646
#ifdef FL_IS_AVR
// AVR: skip RGBWW conversion (too expensive); zero both white channels.
fl::u8 r_pre = loadAndScale0();
fl::u8 g_pre = loadAndScale1();
fl::u8 b_pre = loadAndScale2();
fl::rgbww_partial_reorder(
rgbww.w_placement,
r_pre, g_pre, b_pre,
0, 0,
b0_out, b1_out, b2_out, b3_out, b4_out);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don't silently drop both white channels on AVR.

This branch makes every RGBWW pixel degrade to plain RGB on AVR by always writing 0, 0 for warm/cool white. That produces incorrect output for any configured RGBWW strip and is very hard to diagnose because the failure is silent. Please either reject RGBWW on AVR explicitly or emit a clear fallback warning instead of blacking out both white channels.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pixel_controller.h` around lines 637 - 646, The AVR branch currently
silently zeroes both white channels (in the FL_IS_AVR block that calls
rgbww_partial_reorder with 0,0), which makes RGBWW strips appear as RGB;
instead, detect when the configured strip is RGBWW (using rgbww.w_placement or
the pixel format) and either (a) explicitly reject/abort with a clear
error/return path for rgbww pixels on AVR, or (b) emit a visible warning/log
message and fall back to a safe behavior that preserves white-channel input
(e.g., pass through the original white values or a clear dither/fallback) rather
than writing 0,0; modify the FL_IS_AVR branch around loadAndScale0/loadAndScale2
and the call to rgbww_partial_reorder to implement one of these two options and
ensure the code path uses a logging API or an error return so the failure is not
silent.

…#2558)

Lands all six phases of issue #2558 in a single PR:

PHASE A — Types + variant migration
====================================
- New Rgbww config struct (warm_cct, cool_cct, RGBWW_MODE, EOrderWW,
  optional RgbcctProfile pointer) and RGBWWPixel raw-byte struct.
- New BYTES_PER_PIXEL_RGBWW = 5 constant.
- ChannelOptions.mRgbw -> fl::variant<fl::Empty, Rgbw, Rgbww> mWhiteCfg.
  Empty = plain RGB (replaces the legacy kRGBWInvalid sentinel),
  Rgbw = 4-channel, Rgbww = 5-channel.
- Backward-compat: setRgbw/getRgbw on CLEDController keep working
  (assign/read the Rgbw alternative); new setRgbww/getRgbww parallel API.
- clearWhiteChannel() helper for the explicit "plain RGB" state.

PHASE B — rgb_2_rgbww dispatch shells
======================================
- rgb_2_rgbww_function typedef (Rgbww config by-ref + 5 output pointers)
  and rgb_2_rgbww() inline dispatcher in fl/gfx/rgbww.h.
- Mode stubs (rgb_2_rgbww_colorimetric, _boosted, _user_function) emit
  FL_WARN_ONCE and output five zero bytes when FASTLED_RGBWW is undefined.
- Suppress the warn-once via FASTLED_SUPPRESS_RGBWW_FALLBACK_WARNING.
- User-function callback stored behind lazy Singleton<> (same pattern as
  Rgbw user-function, issue #2424).

PHASE C — Encoder pipeline
===========================
- PixelControllerVtable::loadAndScaleRGBWW (5 output bytes) + typedef.
- PixelIterator stores both Rgbw and Rgbww configs; constructor adds an
  optional Rgbww parameter (defaults to RgbwwInvalid).
- ScaledPixelIteratorRGBWW adapter yielding fl::array<u8, 5>.
- makeScaledPixelRangeRGBWW range helper.
- rgbww_partial_reorder() handles the W-pair byte insertion based on
  EOrderWW (high nibble = warm-W index, low nibble = cool-W index).
- PixelController::loadAndScaleRGBWW pulls RGB from mData, calls
  rgb_2_rgbww, then routes through rgbww_partial_reorder.
- PixelIteratorAny + ReorderingPixelIteratorAny extended with optional
  Rgbww; Channel::showPixels passes both Rgbw and Rgbww from options.
- writeWS2812 in PixelIterator dispatches RGBWW > RGBW > RGB.
- encodeWS2812_RGBWW added to fl/chipsets/encoders/ws2812.h.

PHASE D — Wire solve_rgbcct into colorimetric modes
====================================================
- kRgbwwDefaultProfile: hardcoded RgbcctProfile with SK6812-style R/G/B
  primaries and hardcoded 2700K/6500K Planckian xy_w values (avoids
  static-init order issues; matches cct_to_xy output within 0.002).
- set_rgbww_colorimetric_profile / get_rgbww_colorimetric_profile API.
- When BOTH FASTLED_RGBWW and FASTLED_RGBW_COLORIMETRIC are defined,
  kRGBWWColorimetric and _Boosted dispatch to solve_rgbcct with a chroma-
  driven eta (boosted variant pulls eta toward 0.5 for more W participation).
- When FASTLED_RGBWW is on but FASTLED_RGBW_COLORIMETRIC is off, a clear
  warn-once explains the dependency.

PHASE E — First chipset wrapper + unit tests
=============================================
- WS2812 / SK6812-RGBWW path works end-to-end: any clockless chipset that
  goes through writeWS2812 now emits 5 bytes/pixel when the channel is
  configured with an Rgbww alternative.
- New unit test tests/fl/gfx/rgbww.cpp validates Rgbww defaults, all four
  EOrderWW orderings, dispatch (kRGBWWInvalid -> zeros, colorimetric paths
  link-safe, user-function dispatch), profile get/set API.
- AutoResearch on-device harness for RGBWW hardware validation is left
  for a follow-up PR (no RGBWW strip available to validate it against).

PHASE F — PowerModelRGBWW::toRGB folds in W/WW power
======================================================
- The toRGB() docstring previously called itself "Future API enhancement —
  not yet implemented in power calculations" and dropped the white-channel
  mW values. Now it distributes (white_mW + warm_white_mW) / 3 evenly
  across R/G/B so the brightness limiter doesn't under-budget. Existing
  power_mgt tests updated to the new contract.

KEY DECISIONS
=============
- Scope is Channels API only. Legacy CPixelLEDController<RGB> subclasses
  are unchanged; existing 4-channel RGBW behavior is byte-for-byte
  preserved when ChannelOptions holds an Rgbw alternative.
- fl::variant<fl::Empty, Rgbw, Rgbww> replaces both the optionality and
  the W-channel-count variation in one type. Matches the variant idiom
  already established by ChipsetVariant and the audio Config.
- kRGBWWUserFunction kept as the last enumerator (mirrors the comment on
  RGBW_MODE — dispatch table relies on it being the max value).
- FASTLED_RGBWW gate is independent of FASTLED_RGBW_COLORIMETRIC. The
  former gates the encoder pipeline; the latter gates the math library.
  Real colorimetric output requires both.

Tests: full host suite passes (lint + 305+ unit tests).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@zackees
zackees force-pushed the feat/rgbww-phase-abc branch from 3089458 to 9ae94ae Compare May 30, 2026 05:42

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/fl/channels/channel.cpp.hpp`:
- Line 199: The white config is applied via applyWhiteCfg(*this, options) but
mSettings is not updated, so showPixels() still reads old
mSettings.rgbw()/rgbww(); update mSettings to reflect the incoming
options/config so settings and encoding stay in sync: after calls to
applyWhiteCfg(*this, ...) in both Channel constructors and in
Channel::applyConfig(), assign mSettings = options (or merge the relevant white
config into mSettings) so mSettings.rgbw()/rgbww() matches
ChannelOptions::mWhiteCfg used to configure the channel.

In `@src/fl/gfx/rgbww.cpp.hpp`:
- Around line 76-88: The singleton currently stores a raw pointer causing
potential dangling-pointer bugs; change RgbwwColorimetricState::profile to an
owning fl::shared_ptr<const colorimetric_detail::RgbcctProfile> (or
fl::unique_ptr if exclusive ownership is desired), update
set_rgbww_colorimetric_profile to accept and store an fl::shared_ptr<const
colorimetric_detail::RgbcctProfile> (or make a deep copy and wrap it), and
modify get_rgbww_colorimetric_profile to return the stored profile.get()
(falling back to &kRgbwwDefaultProfile if the shared_ptr is null); also update
callers to pass an owning shared_ptr or adapt to the new signature and ensure
lifetime is managed by the singleton via fl::shared_ptr.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7ab3563d-2b62-4c2a-aaab-2383e52fd501

📥 Commits

Reviewing files that changed from the base of the PR and between 3089458 and 9ae94ae.

📒 Files selected for processing (20)
  • examples/RGBWW/RGBWW.ino
  • src/fl/channels/channel.cpp.hpp
  • src/fl/channels/cled_controller.h
  • src/fl/channels/options.h
  • src/fl/chipsets/encoders/encoder_constants.h
  • src/fl/chipsets/encoders/pixel_iterator.h
  • src/fl/chipsets/encoders/pixel_iterator_adapters.h
  • src/fl/chipsets/encoders/ws2812.h
  • src/fl/gfx/_build.cpp.hpp
  • src/fl/gfx/pixel_iterator_any.h
  • src/fl/gfx/rgbw.cpp.hpp
  • src/fl/gfx/rgbw.h
  • src/fl/gfx/rgbww.cpp.hpp
  • src/fl/gfx/rgbww.h
  • src/fl/gfx/rgbww_pixel.h
  • src/pixel_controller.h
  • src/power_mgt.h
  • tests/fastled_core.cpp
  • tests/fl/gfx/rgbww.cpp
  • tests/power_mgt.cpp
✅ Files skipped from review due to trivial changes (2)
  • src/fl/chipsets/encoders/encoder_constants.h
  • src/fl/gfx/rgbw.h
🚧 Files skipped from review as they are similar to previous changes (15)
  • src/power_mgt.h
  • src/fl/chipsets/encoders/ws2812.h
  • tests/power_mgt.cpp
  • tests/fastled_core.cpp
  • src/fl/gfx/rgbww_pixel.h
  • src/fl/gfx/_build.cpp.hpp
  • src/fl/channels/options.h
  • examples/RGBWW/RGBWW.ino
  • src/pixel_controller.h
  • tests/fl/gfx/rgbww.cpp
  • src/fl/gfx/rgbw.cpp.hpp
  • src/fl/chipsets/encoders/pixel_iterator_adapters.h
  • src/fl/channels/cled_controller.h
  • src/fl/gfx/rgbww.h
  • src/fl/chipsets/encoders/pixel_iterator.h

setTemperature(options.mTemperature);
setDither(options.mDitherMode);
setRgbw(options.mRgbw);
applyWhiteCfg(*this, options);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep mSettings in sync with the applied white config.

showPixels() builds ReorderingPixelIteratorAny from mSettings.rgbw()/rgbww(), but these paths only call applyWhiteCfg(*this, ...). In the code shown here there is no matching mSettings = options/config.options, so a channel configured through ChannelOptions::mWhiteCfg will still encode as plain RGB on the next showPixels().

Possible fix
     setCorrection(options.mCorrection);
     setTemperature(options.mTemperature);
     setDither(options.mDitherMode);
-    applyWhiteCfg(*this, options);
+    mSettings = options;
+    applyWhiteCfg(*this, mSettings);

Apply the same sync in both constructors and in Channel::applyConfig().

Also applies to: 225-225, 245-245, 401-403

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fl/channels/channel.cpp.hpp` at line 199, The white config is applied via
applyWhiteCfg(*this, options) but mSettings is not updated, so showPixels()
still reads old mSettings.rgbw()/rgbww(); update mSettings to reflect the
incoming options/config so settings and encoding stay in sync: after calls to
applyWhiteCfg(*this, ...) in both Channel constructors and in
Channel::applyConfig(), assign mSettings = options (or merge the relevant white
config into mSettings) so mSettings.rgbw()/rgbww() matches
ChannelOptions::mWhiteCfg used to configure the channel.

Comment thread src/fl/gfx/rgbww.cpp.hpp
Comment on lines +76 to +88
struct RgbwwColorimetricState {
const colorimetric_detail::RgbcctProfile* profile = nullptr;
};
} // namespace

void set_rgbww_colorimetric_profile(const colorimetric_detail::RgbcctProfile* profile) FL_NOEXCEPT {
fl::Singleton<RgbwwColorimetricState>::instance().profile = profile;
}

const colorimetric_detail::RgbcctProfile* get_rgbww_colorimetric_profile() FL_NOEXCEPT {
const colorimetric_detail::RgbcctProfile* p =
fl::Singleton<RgbwwColorimetricState>::instance().profile;
return p != nullptr ? p : &kRgbwwDefaultProfile;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Own the active profile instead of retaining a borrowed pointer.

set_rgbww_colorimetric_profile() stores the caller's pointer in global singleton state and every colorimetric call dereferences it later. Passing a stack-local RgbcctProfile here turns this into a dangling-pointer/use-after-scope bug; keep an owned copy in the singleton or require an owning handle.

As per coding guidelines, "Use proper RAII patterns with smart pointers (fl::shared_ptr, fl::unique_ptr) or moveable wrapper objects instead of raw pointers".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fl/gfx/rgbww.cpp.hpp` around lines 76 - 88, The singleton currently
stores a raw pointer causing potential dangling-pointer bugs; change
RgbwwColorimetricState::profile to an owning fl::shared_ptr<const
colorimetric_detail::RgbcctProfile> (or fl::unique_ptr if exclusive ownership is
desired), update set_rgbww_colorimetric_profile to accept and store an
fl::shared_ptr<const colorimetric_detail::RgbcctProfile> (or make a deep copy
and wrap it), and modify get_rgbww_colorimetric_profile to return the stored
profile.get() (falling back to &kRgbwwDefaultProfile if the shared_ptr is null);
also update callers to pass an owning shared_ptr or adapt to the new signature
and ensure lifetime is managed by the singleton via fl::shared_ptr.

@zackees
zackees merged commit d77d6e0 into master May 30, 2026
9 checks passed
zackees added a commit that referenced this pull request May 30, 2026
…plyConfig (#2582)

Channel::showPixels() builds ReorderingPixelIteratorAny from
mSettings.rgbw()/rgbww(), but the constructor and applyConfig() never
assigned mSettings from the incoming ChannelOptions. As a result any
channel configured via ChannelOptions::mWhiteCfg silently encoded as
plain RGB. Assign mSettings = options/config.options before calling
applyWhiteCfg so the variant survives to showPixels().

Addresses CodeRabbit finding A3 from meta #2580 (originally from #2560).
zackees added a commit that referenced this pull request May 30, 2026
…2588)

set_rgbww_colorimetric_profile() previously stored the caller's raw
pointer in singleton state. Passing a stack-local RgbcctProfile turned
this into a use-after-scope on the next get_rgbww_colorimetric_profile()
call. Store an owned copy instead; nullptr still reverts to the default
profile. Public API signature is unchanged.

Addresses CodeRabbit finding A4 from meta #2580 (originally from #2560).
@zackees
zackees deleted the feat/rgbww-phase-abc branch May 30, 2026 20:02
zackees added a commit that referenced this pull request May 30, 2026
…identity (#2604)

`fl_gfx_rgbww` "rgbww colorimetric profile get/set API" was failing on
master because the test asserted pointer identity:

  set_rgbww_colorimetric_profile(&custom);
  const auto* after = get_rgbww_colorimetric_profile();
  FL_CHECK(after == &custom);   // FAILS

PR #2580 (CodeRabbit finding A4 from #2560) deliberately changed
set_*/get_* to copy into singleton-owned storage and return a pointer
to that copy — never the caller's address. The change fixed a
real dangling-pointer bug (callers typically pass `&local_var` from
`setup()`, which became invalid once `setup()` returned). If the
old `after == &caller_ptr` assertion were to pass now, it would mean
the dangling-pointer behavior had been re-introduced.

Update the test to assert what the implementation actually promises:

  - `after != nullptr`              — basic sanity
  - `after != &custom`              — distinct from caller's address
  - `after != &kRgbwwDefaultProfile` — set() actually took effect
  - `after->warm_path.lum_w == 0.5f` — value flowed through correctly

The new assertions catch a regression to the dangling-pointer behavior
(any future change that returns the caller's pointer fails
`after != &custom`).

Verified:
  bash test fl_gfx_rgbww --cpp   — passes
  bash test fl_gfx_rgbww --debug — passes (ASAN/UBSAN/LSAN)

Fixes #2603
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.

feat(rgbww): 5-channel RGB+WW (warm/cool white) support via Channels API (Phase 3 of #2545)

1 participant