Skip to content

fix(rgbw): default source = native LED gamut + D65; named-gamut opt-in - #2711

Merged
zackees merged 4 commits into
masterfrom
fix/native-input-gamut-default-2710
Jun 3, 2026
Merged

zackees merged 4 commits into
masterfrom
fix/native-input-gamut-default-2710

Conversation

@zackees

@zackees zackees commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

Closes #2710.

#2705 added the source-RGB → LED-XYZ transform with kRgbwDefaultProfile defaulting to Rec709/sRGB primaries + D65. That silently clipped saturated inputs to the sRGB sub-volume of the LED's native gamut — RGB=(255,0,0) on a typical SK6812 strip drove the LED red diode to ~70 % of its capability, leaving the rest unreachable through the public API. Users had no indication this was happening; they expected FastLED to drive their LEDs at full saturation as it always has.

Behavior change

kRgbwDefaultProfile.input_xy_r/g/b now mirror the profile's own LED xy_r/g/b (was sRGB), so saturated inputs hit the LED gamut at full saturation. input_xy_w stays at D65 so neutral inputs land on a standard daylight white. Same applies to kRgbwwDefaultProfile (RGBWW warm + cool paths).

Net effect for users on the default profile:

Input Before (sRGB default) After (native default)
RGB=(255,0,0) sRGB red (~70% LED red) LED red diode full-drive
RGB=(255,255,255) D65 (W diode + small RGB) D65 (W diode + small RGB) — unchanged
RGB=(0,0,255) sRGB blue → out-of-hull → projected (#2708) LED blue diode full-drive

Opt-in API for named gamuts

Users with sRGB content (ambilight, video bridges) write one line at setup:

fl::set_input_gamut(&my_profile, fl::InputGamut::Rec709);

The new enum + setter:

enum class InputGamut : u8 {
    Native,        // Input primaries == this profile's LED primaries + D65
    Rec709,        // sRGB / Rec.709 + D65
    Rec2020,       // Rec.2020 (UHDTV) + D65
    DciP3D65,      // DCI-P3 with D65 (consumer displays — e.g. Apple)
    DciP3D60,      // DCI-P3 with ACES D60 (cinema mastering)
};

void set_input_gamut(DiodeProfile* profile, InputGamut g) noexcept;
void set_input_gamut(DiodeProfile* profile, InputGamut g,
                     const float white_xy[2]) noexcept;

The white-override overload covers niche cases like D50 photography workflow or any custom calibration target.

Tests

fl_gfx_rgbw_colorimetric adds:

  • default profile carries native-LED + D65 source space (#2710) — asserts input_xy_* mirror xy_* and input_xy_w == D65.
  • source matrix matches published sRGB->XYZ matrix (Rec709 opt-in) — existing sRGB matrix-derivation check now opts into Rec709 via set_input_gamut() first.
  • set_input_gamut: Native copies LED primaries — trashes input_xy_*, then proves Native restores them from xy_*.
  • set_input_gamut: named gamuts populate canonical primaries — hits Rec709 / Rec2020 / DCI-P3 D65 / DCI-P3 D60 and asserts canonical primary + white values.
  • set_input_gamut: white override honored — covers the overload (D50 in the test).
  • set_input_gamut: null profile is a no-op.

Drive-by

Removes compare_rgbw.py, a one-off scratch comparison harness that slipped into master via #2709's squash-merge despite being deleted on the branch.

Test plan

  • bash lint clean
  • bash test --cpp --clean passes 308/308 including the 6 new gamut-API cases
  • CI green
  • CodeRabbit review addressed

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Add named input gamuts (Native, Rec709, Rec2020, DCI‑P3 D65/D60) and support for a custom white point; FastLED API now lets callers configure input gamut per profile.
  • Changes

    • Default RGBW/RGBWW input semantics now use native LED primaries with D65 white.
  • Bug Fixes / Reliability

    • Invalidate colorimetric caches when input gamut changes to avoid stale results.
  • Chores

    • Removed legacy Python RGBW comparison tool.
  • Tests

    • Expanded colorimetric tests for gamut selection and behavior.

#2710)

Closes #2710.

#2705 added the source-RGB → LED-XYZ transform with `kRgbwDefaultProfile`
defaulting to Rec709/sRGB primaries + D65. That silently clipped saturated
inputs to the sRGB sub-volume of the LED's native gamut — `RGB=(255,0,0)`
on a typical SK6812 strip drove the LED red diode to ~70 % of its
capability, leaving the rest unreachable through the public API.

Flips the default to **native LED gamut + D65 white**:
  - `kRgbwDefaultProfile.input_xy_r/g/b` now mirror the profile's own
    LED `xy_r/g/b` (was sRGB), so saturated inputs hit the LED gamut at
    full saturation.
  - `input_xy_w` stays at D65 so neutral inputs land on a standard
    daylight white.
  - Same applies to `kRgbwwDefaultProfile` (RGBWW warm + cool paths).

Adds a small opt-in API for users who explicitly want standard
color-space input semantics:

    enum class InputGamut : u8 {
        Native, Rec709, Rec2020, DciP3D65, DciP3D60
    };
    void set_input_gamut(DiodeProfile* profile, InputGamut g) noexcept;
    void set_input_gamut(DiodeProfile* profile, InputGamut g,
                         const float white_xy[2]) noexcept;

Users with sRGB content (ambilight, video bridges) write one line at
setup: `fl::set_input_gamut(&my_profile, fl::InputGamut::Rec709);`. The
white-override overload covers niche cases like D50 photography workflow
or D60 ACES theatrical mastering.

Tests
=====
- `default profile carries native-LED + D65 source space (#2710)` —
  asserts input_xy_* mirror xy_* and input_xy_w == D65.
- `source matrix matches published sRGB->XYZ matrix (Rec709 opt-in)` —
  the existing sRGB matrix-derivation check now opts into Rec709 via
  set_input_gamut() before building M_src.
- `set_input_gamut: Native copies LED primaries` — trashes input_xy_*
  then proves Native restores them from xy_*.
- `set_input_gamut: named gamuts populate canonical primaries` —
  hits Rec709 / Rec2020 / DCI-P3 D65 / DCI-P3 D60 and asserts canonical
  primary + white-point values.
- `set_input_gamut: white override honored` — covers the overload that
  takes a custom white (D50 in the test).
- `set_input_gamut: null profile is a no-op` — defensive guard parity
  with `set_rgbw_colorimetric_profile(nullptr)`.

Drive-by
========
Removes `compare_rgbw.py`, a one-off scratch comparison harness that
slipped into master via #2709's squash-merge despite being deleted on
the branch.

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

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: afbce1f6-9fb9-42c7-b092-d5cf4314ba47

📥 Commits

Reviewing files that changed from the base of the PR and between 79cf584 and 876831a.

📒 Files selected for processing (1)
  • src/FastLED.h

📝 Walkthrough

Walkthrough

Switch default RGBW/RGBWW input chromaticities to native LED primaries with D65 white, add a public InputGamut enum and two set_input_gamut() overloads (including optional white override), implement cache invalidation for mutated profiles, remove compare_rgbw.py, and update/extend tests plus minor CI/test formatting tweaks.

Changes

Input Gamut Colorimetric Defaults and API

Layer / File(s) Summary
Public API contract: InputGamut enum and set_input_gamut declarations
src/fl/gfx/rgbw.h
Adds InputGamut enum and two set_input_gamut() overloads; header docs now state default input = native LED primaries + D65 and document legacy fallback when input_xy_w[1] == 0.0f.
set_input_gamut implementation with named gamut constants & cache invalidation
src/fl/gfx/rgbw.cpp.hpp
Defines named-gamut chromaticities and implements set_input_gamut() (Native copies LED primaries; named gamuts apply canonical primaries/whites; optional white override). Implements invalidate_colorimetric_caches_for() and a no-op stub for non-colorimetric builds.
Default profile input gamut switch to native LED primaries
src/fl/gfx/rgbw.cpp.hpp, src/fl/gfx/rgbww.cpp.hpp
Updates kRgbwDefaultProfile and kRgbwwDefaultProfile (warm/cool) to use measured native LED xy_r/g/b for input_xy_* while keeping D65 white; inline comments direct callers to use set_input_gamut() for alternate semantics.
Tests: default profiles and set_input_gamut API coverage
tests/fl/gfx/rgbw_colorimetric.cpp, tests/fl/gfx/rgbww.cpp
Default-profile test now asserts input_xy_r/g/b match LED primaries; Rec709/Rec2020/DCI-P3 validations are opt-in via set_input_gamut(&p, ...). Adds tests covering named gamuts, custom white override, nullptr no-op, and a rgbww default-profile warm/cool test.
CI/tests small formatting tweaks
ci/autoresearch/phases.py, ci/tests/test_fbuild_compile_many.py, ci/tests/test_sketch_filter.py
Minor non-behavioral reformatting: multiline condition, condensed helper signature, and multi-line assertion message formatting.

Sequence Diagram

sequenceDiagram
  participant CFastLED
  participant fl_set_input_gamut as fl::set_input_gamut
  participant DiodeProfile
  participant CacheInvalidator as invalidate_colorimetric_caches_for
  CFastLED->>fl_set_input_gamut: call setInputGamut(profile, gamut[, white_xy])
  fl_set_input_gamut->>DiodeProfile: mutate input_xy_r/g/b/w
  fl_set_input_gamut->>CacheInvalidator: request cache invalidation for profile
  CacheInvalidator->>ProfileCache: clear cached profile/LUT state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 I nibble on primaries, D65 so bright,
Native LED greens and reds take flight,
InputGamut hums, set_input_gamut hops in,
Tests check the bounds, caches cleared with a grin,
Colors leap truer — a rabbit's soft delight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 56.25% 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 title directly describes the main change: switching the default RGBW input source from Rec709/sRGB to native LED gamut plus D65, and introducing named-gamut opt-in capability.
Linked Issues check ✅ Passed All coding requirements from issue #2710 are fully met: default input gamut changed to native LED primaries with D65 white, InputGamut enum added with five modes, set_input_gamut functions implemented with white override support, all tests updated and extended, and cache invalidation handled appropriately.
Out of Scope Changes check ✅ Passed All changes align with PR objectives: RGBW/RGBWW defaults updated, InputGamut API added, tests revised, CFastLED wrappers added per Public Settings Pattern. Minor formatting fixes in CI Python files are acceptable drive-by cleanups. The compare_rgbw.py removal is explicitly justified as a test harness no longer needed.

✏️ 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 fix/native-input-gamut-default-2710

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.

coderabbitai[bot]
coderabbitai Bot previously requested changes Jun 3, 2026

@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

🧹 Nitpick comments (1)
src/fl/gfx/rgbww.cpp.hpp (1)

53-84: ⚡ Quick win

Consider guarding the native-primary duplication for RGBWW.

input_xy_r/g/b are hand-copied from xy_r/g/b in both warm and cool paths. If the LED chromaticities are later retuned, input_xy_* can silently drift out of sync, since (unlike kRgbwDefaultProfile, which is covered by the test at Lines 252-272) there is no equivalent test asserting kRgbwwDefaultProfile.warm_path.input_xy_* == xy_*. A small static assertion or a dedicated test would lock the "native LED gamut" default contract in place.

🤖 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 53 - 84, The warm_path and cool_path
entries in kRgbwwDefaultProfile duplicate native-primary values (xy_r/g/b vs
input_xy_r/g/b) which can drift; add a guard to ensure they remain identical by
either adding compile-time static assertions or a unit test that compares
kRgbwwDefaultProfile.warm_path.input_xy_r/g/b ==
kRgbwwDefaultProfile.warm_path.xy_r/g/b and the same for cool_path (and
fail/build on mismatch). Locate kRgbwwDefaultProfile and implement
assertions/tests referencing the struct members warm_path, cool_path, xy_r,
xy_g, xy_b, input_xy_r, input_xy_g, input_xy_b to lock the native LED gamut
contract.
🤖 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/gfx/rgbw.cpp.hpp`:
- Around line 234-268: set_input_gamut currently mutates profile->input_xy_* in
place but does not mark any cache invalid, so get_cache() /
rebuild_lut_if_stale() keep using the stale M_src/LUT; to fix, add a
cache-invalidation step inside set_input_gamut(DiodeProfile*, InputGamut, const
float[]) (and the two-arg overload) that updates a version/id on the profile
that the cache key reads (e.g. bump profile->cache_version or call
profile_invalidate_cache(profile)), and then update get_cache() /
rebuild_lut_if_stale() to include that version/id in their cache lookup so any
in-place changes to profile->input_xy_* will force cache recomputation of
M_src/LUT.

In `@src/fl/gfx/rgbw.h`:
- Around line 94-100: Change the public API for set_input_gamut(DiodeProfile*
profile, InputGamut g, const float white_xy[2]) to use fl::span<const float, 2>
for the white_xy parameter, update the header doc to remove the "must point"
wording, and update the implementation in set_input_gamut (and any callers) to
accept a span (no nullptr semantics) and rely on the existing 2-arg overload
set_input_gamut(DiodeProfile*, InputGamut) for the default/D65 behavior; ensure
the implementation checks span.size()==2 and handles missing span by calling the
2-arg overload.

---

Nitpick comments:
In `@src/fl/gfx/rgbww.cpp.hpp`:
- Around line 53-84: The warm_path and cool_path entries in kRgbwwDefaultProfile
duplicate native-primary values (xy_r/g/b vs input_xy_r/g/b) which can drift;
add a guard to ensure they remain identical by either adding compile-time static
assertions or a unit test that compares
kRgbwwDefaultProfile.warm_path.input_xy_r/g/b ==
kRgbwwDefaultProfile.warm_path.xy_r/g/b and the same for cool_path (and
fail/build on mismatch). Locate kRgbwwDefaultProfile and implement
assertions/tests referencing the struct members warm_path, cool_path, xy_r,
xy_g, xy_b, input_xy_r, input_xy_g, input_xy_b to lock the native LED gamut
contract.
🪄 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: f0edddb2-83e0-4c3d-9f83-1ed90b5cdefc

📥 Commits

Reviewing files that changed from the base of the PR and between 7412393 and fc0703b.

📒 Files selected for processing (5)
  • compare_rgbw.py
  • src/fl/gfx/rgbw.cpp.hpp
  • src/fl/gfx/rgbw.h
  • src/fl/gfx/rgbww.cpp.hpp
  • tests/fl/gfx/rgbw_colorimetric.cpp
💤 Files with no reviewable changes (1)
  • compare_rgbw.py

Comment thread src/fl/gfx/rgbw.cpp.hpp Resolved
Comment thread src/fl/gfx/rgbw.h Resolved
zackees and others added 2 commits June 3, 2026 15:36
bash lint reformatted three CI files during PR #2711 review work. No
functional change — purely line-break/whitespace adjustments that ruff
flagged as drift from the current format profile.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Three follow-ups from the CodeRabbit review:

1. **(major) Cache invalidation on in-place gamut mutation** —
   set_input_gamut() rewrites profile->input_xy_* in place, but the
   ColorimetricCacheHolder and LutStateHolder are keyed on (profile_ptr,
   cct). Without invalidation, the cache held stale M_src/LUT entries
   after a gamut switch on the currently active profile, producing
   deterministic wrong colors. Now the active per-process caches are
   evicted whenever set_input_gamut() mutates a profile that matches
   the cache key. No-op in the FASTLED_RGBW_COLORIMETRIC=0 build (no
   cache exists to invalidate).

2. **(contract) white_xy doc mismatch** — The header doc said the
   `white_xy` override "must point to a 2-float array" but the impl
   already accepted nullptr as "use the gamut's reference white"
   (equivalent to the 2-arg overload). Doc now matches behavior. Kept
   the raw-array signature instead of switching to fl::span<const
   float, 2> — the header sits low in the include graph and pulling
   fl/stl/span.h here would be a heavier change than the contract bug
   warrants; the 2-arg overload remains the recommended call site for
   the default-white path.

3. **(nitpick) RGBWW native-gamut guard** — Added an explicit test
   asserting kRgbwwDefaultProfile.warm_path / cool_path keep
   input_xy_* mirroring xy_* and input_xy_w pinned at D65. Symmetric
   to the existing assertion at rgbw_colorimetric.cpp:252-272; locks
   the native-LED-gamut contract on both warm and cool paths so future
   chromaticity retuning can't silently desync source from emitter.

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

zackees commented Jun 3, 2026

Copy link
Copy Markdown
Member Author

Heads-up — PR #2715 just codified a Public Settings Pattern rule into agents/docs/cpp-standards.md: new library-wide configuration setters must be exposed on the CFastLED god instance (FastLED.setX(...)), with the fl:: free function as a thin backing implementation. Exemplar: CFastLED::setPowerModel (src/FastLED.h:1455) → fl::set_power_model.

fl::set_input_gamut(...) added in this PR currently exists only as a free function — same shape as the pre-existing fl::set_rgbw_colorimetric_profile (which #2715 just wrapped on master). Both are explicitly grandfathered in the new rule, but the goal is to backfill the wrappers so users have a discoverable FastLED.setInputGamut(...) entry point matching every other global setting in the library.

Two options, whichever is easier for you:

Option A (preferred, cleanest history): fold the wrapper into this PR. Roughly:

// src/FastLED.h, near setRgbwColorimetricProfile (which PR #2715 adds)
inline void setInputGamut(fl::DiodeProfile* profile, fl::InputGamut g) FL_NOEXCEPT {
    fl::set_input_gamut(profile, g);
}
inline void setInputGamut(fl::DiodeProfile* profile, fl::InputGamut g,
                          const float white_xy[2]) FL_NOEXCEPT {
    fl::set_input_gamut(profile, g, white_xy);
}

Then update the PR body's "Opt-in API for named gamuts" example to read:

FastLED.setInputGamut(&my_profile, fl::InputGamut::Rec709);

…and the same in examples/RGBWW/RGBWW.ino (and any other example referencing the free function form).

Option B: ship #2711 as-is and I'll open a follow-up to wrap it after merge. Slightly more churn but no extra work on your end.

Either way the free function stays callable, so tests keep working unchanged.

(Will need a tiny rebase against master after #2715 lands — src/FastLED.h will already include fl/gfx/rgbw.h and have the setRgbwColorimetricProfile wrapper as a placement anchor.)

zackees added a commit that referenced this pull request Jun 3, 2026
…al setters

Removes the grandfathered exceptions section from the Public Settings
Pattern docs. Both names that were allowlisted in the initial commit of
this PR were introduced after the policy itself was being defined, so
neither was historically grandfathered:

- `fl::set_rgbw_colorimetric_profile` is already wrapped on `CFastLED`
  (`CFastLED::setRgbwColorimetricProfile`) in this PR, so it no longer
  needs an exception.
- `fl::set_input_gamut` (#2710) is introduced in PR #2711 without a
  `CFastLED` wrapper. The wrapper must be added before that PR merges.

Updated files:
- `.coderabbit.yaml`
- `agents/docs/cpp-standards.md`
- `.claude/agents/architecture-reviewer-agent.md`
- `.claude/commands/code_review.md`

Addresses CodeRabbit review on PR #2715.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@zackees

zackees commented Jun 3, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review please — three follow-up commits (9e5831a, 79cf584) address all findings from your previous review:

  1. Cache invalidation (rgbw.cpp.hpp:268) — set_input_gamut now evicts the active ColorimetricCacheHolder and LutStateHolder entries when the mutated profile matches the cache key. Forward-declared invalidator with a no-op stub in the FASTLED_RGBW_COLORIMETRIC=0 path.

  2. white_xy contract (rgbw.h:100) — Doc now matches impl (nullptr → use gamut's reference white, equivalent to the 2-arg overload). Kept the raw-array signature rather than refactoring to fl::span<const float, 2> to avoid pulling fl/stl/span.h into a low-level public header — happy to switch if you'd prefer.

  3. RGBWW guard (rgbww.cpp.hpp:53-84) — Added kRgbwwDefaultProfile carries native-LED + D65 source space (#2710) test in tests/fl/gfx/rgbww.cpp, mirrors the existing RGBW assertion and locks both warm_path and cool_path.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch PR details and diff
gh pr view 2711 --repo FastLED/FastLED --json title,body,commits,files,state

echo "=== PR DIFF ==="
gh pr diff 2711 --repo FastLED/FastLED

Length of output: 49686



@zackees: Thorough review of the final commit set (9e5831a + 79cf584) — all three previous findings are properly addressed. Here's the full breakdown:


✅ Cache invalidation (rgbw.cpp.hpp)

The forward-declaration-in-anonymous-namespace pattern is valid C++ — all namespace {} blocks within a TU share the same internal linkage, so the forward-declare-then-define approach works correctly. The real implementation:

if (ch.cached_for == profile) { ch.cached_for = nullptr; ch.cached_cct = 0; }
if (lh.built_for == profile)  { lh.built_for = nullptr;  lh.built_cct = 0; }

…correctly evicts both ColorimetricCacheHolder and LutStateHolder on pointer equality. The no-op stub in the FASTLED_RGBW_COLORIMETRIC=0 path keeps the call site clean without any #if guard inside set_input_gamut. ✓


✅ white_xy contract (rgbw.h:100)

Doc now accurately reflects the implementation:

white_xy either points to a 2-float (x, y) chromaticity OR is nullptr to fall back to the gamut's standard reference white (equivalent to the 2-argument overload above).

Raw-array signature kept — agree that pulling fl/stl/span.h into this low-level header for a single parameter would be disproportionate. Per the retrieved learning, any fl::span migration should sweep all handler types at once. ✓


✅ RGBWW native-gamut guard (rgbww.cpp)

The new test checks both warm_path and cool_path for all six input_xy_[rg b][01] components at 1e-6 tolerance plus D65 white at 1e-4 — more thorough than the RGBW counterpart it mirrors. ✓


Minor nit (non-blocking)

In "set_input_gamut: Native copies LED primaries" the [1] components of G and B are not verified:

FL_CHECK_CLOSE(p.input_xy_r[0], p.xy_r[0], 1e-6f);
FL_CHECK_CLOSE(p.input_xy_g[0], p.xy_g[0], 1e-6f);  // [1] not checked
FL_CHECK_CLOSE(p.input_xy_b[0], p.xy_b[0], 1e-6f);  // [1] not checked

The other tests in the same suite are intentionally selective on representative fields, and the RGBWW test and the "default profile" test cover [1] exhaustively, so there's no coverage gap in practice. Mentioning it only for completeness — not a blocker.


Regarding CFastLED::setInputGamut

The note from the first comment in the chain about wrapping fl::set_input_gamut on CFastLED per the Public Settings Pattern (#2715) is outside the scope of this PR. Option B (follow-up) is fine; the free function API stays callable by tests and advanced users until that wrapper lands.


Overall the implementation is correct, well-documented, and test-covered. Happy to approve.

[approve]


🧠 Learnings used
Learnt from: zackees
Repo: FastLED/FastLED PR: 2683
File: src/fl/stl/cstdio.h:180-189
Timestamp: 2026-06-02T17:57:08.536Z
Learning: In `src/fl/stl/cstdio.h`, the `FASTLED_TESTING` injection layer intentionally uses raw pointer + length signatures (e.g., `write_bytes_handler_t = fl::function<size_t(const u8*, size_t)>`) to stay consistent with all other handler types in that layer (`print_handler_t`, `println_handler_t`, `available_handler_t`, `read_handler_t`). A one-off switch to `fl::span<const u8>` for only `write_bytes_handler_t` was explicitly deferred; the preference is a full-layer sweep converting all handlers at once.

…attern

`fl::set_input_gamut` (#2710) is a library-wide global setter. Under the
Public Settings Pattern in agents/docs/cpp-standards.md, every public
fl:: global setter must ship with a thin inline `CFastLED` wrapper that
becomes the documented user-facing call site. The two-arg and three-arg
overloads now have matching `CFastLED::setInputGamut` wrappers.

Removes the implicit grandfathered exception this function was relying
on in PR #2715 — that PR's follow-up commit explicitly dropped the
allowlist, so this wrapper is now required before merge rather than
deferred.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@zackees
zackees dismissed coderabbitai[bot]’s stale review June 3, 2026 23:29

CodeRabbit's findings against fc0703b were addressed in follow-up commits 9e5831a + 79cf584 — cache invalidation hook added to set_input_gamut, white_xy contract doc fixed, RGBWW native-gamut guard test added. CR's own status check is SUCCESS on the new HEAD; CI is 7/7 green. Dismissing the stale review since CR did not auto-update.

@zackees
zackees merged commit ca258f4 into master Jun 3, 2026
13 checks passed
@zackees
zackees deleted the fix/native-input-gamut-default-2710 branch June 3, 2026 23:33
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 3, 2026
zackees added a commit that referenced this pull request Jun 4, 2026
Codifies the long-implicit rule that new library-wide configuration
setters must be exposed on the `CFastLED` god instance (e.g.
`FastLED.setX(...)`) rather than as bare `fl::set_x(...)` free
functions. The free function may exist for ADL / testability, but
the documented call site is the god instance.

Motivated by PR #2711, which added `fl::set_input_gamut(...)` as a
free function only — following the unwrapped precedent of
`fl::set_rgbw_colorimetric_profile`. Neither has a `FastLED.setX()`
entry point, so users don't discover them. Both are now grandfathered
exceptions; new code must wrap.

Changes:
- `agents/docs/cpp-standards.md`: New "Public Settings Pattern" section
  with rules, exemplar (`setPowerModel` → `set_power_model`), and a
  grandfathered allowlist.
- `CLAUDE.md`: One-liner pointer in the task table and Code Standards
  section so agents see the rule on entry.
- `.coderabbit.yaml`: `path_instructions` for `src/fl/**/*.h`,
  `src/FastLED.h`, and `src/fl/gfx/**` telling CodeRabbit to flag bare
  new `fl::set_* / enable_* / disable_* / use_*` declarations without
  a matching `CFastLED` wrapper as HIGH severity, with the
  grandfathered allowlist honored.
- `.claude/agents/architecture-reviewer-agent.md`: API Surface check
  step gains a "Public Settings Pattern enforcement" subsection.
- `.claude/commands/code_review.md`: New rule block before "SIGNED
  INTEGER OVERFLOW", plus a counter in the violations summary.
- `src/FastLED.h`: Backfills `CFastLED::setRgbwColorimetricProfile()`
  and `getRgbwColorimetricProfile()` — thin `inline` delegators to the
  existing `fl::` free functions. `setInputGamut` is intentionally left
  for PR #2711 to add alongside its own free function (it isn't on
  master yet).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 4, 2026
…al setters

Removes the grandfathered exceptions section from the Public Settings
Pattern docs. Both names that were allowlisted in the initial commit of
this PR were introduced after the policy itself was being defined, so
neither was historically grandfathered:

- `fl::set_rgbw_colorimetric_profile` is already wrapped on `CFastLED`
  (`CFastLED::setRgbwColorimetricProfile`) in this PR, so it no longer
  needs an exception.
- `fl::set_input_gamut` (#2710) is introduced in PR #2711 without a
  `CFastLED` wrapper. The wrapper must be added before that PR merges.

Updated files:
- `.coderabbit.yaml`
- `agents/docs/cpp-standards.md`
- `.claude/agents/architecture-reviewer-agent.md`
- `.claude/commands/code_review.md`

Addresses CodeRabbit review on PR #2715.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
zackees added a commit that referenced this pull request Jun 4, 2026
* docs(cpp): enforce Public Settings Pattern for global setters

Codifies the long-implicit rule that new library-wide configuration
setters must be exposed on the `CFastLED` god instance (e.g.
`FastLED.setX(...)`) rather than as bare `fl::set_x(...)` free
functions. The free function may exist for ADL / testability, but
the documented call site is the god instance.

Motivated by PR #2711, which added `fl::set_input_gamut(...)` as a
free function only — following the unwrapped precedent of
`fl::set_rgbw_colorimetric_profile`. Neither has a `FastLED.setX()`
entry point, so users don't discover them. Both are now grandfathered
exceptions; new code must wrap.

Changes:
- `agents/docs/cpp-standards.md`: New "Public Settings Pattern" section
  with rules, exemplar (`setPowerModel` → `set_power_model`), and a
  grandfathered allowlist.
- `CLAUDE.md`: One-liner pointer in the task table and Code Standards
  section so agents see the rule on entry.
- `.coderabbit.yaml`: `path_instructions` for `src/fl/**/*.h`,
  `src/FastLED.h`, and `src/fl/gfx/**` telling CodeRabbit to flag bare
  new `fl::set_* / enable_* / disable_* / use_*` declarations without
  a matching `CFastLED` wrapper as HIGH severity, with the
  grandfathered allowlist honored.
- `.claude/agents/architecture-reviewer-agent.md`: API Surface check
  step gains a "Public Settings Pattern enforcement" subsection.
- `.claude/commands/code_review.md`: New rule block before "SIGNED
  INTEGER OVERFLOW", plus a counter in the violations summary.
- `src/FastLED.h`: Backfills `CFastLED::setRgbwColorimetricProfile()`
  and `getRgbwColorimetricProfile()` — thin `inline` delegators to the
  existing `fl::` free functions. `setInputGamut` is intentionally left
  for PR #2711 to add alongside its own free function (it isn't on
  master yet).

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

* docs(cpp): drop grandfathered allowlist; require wrapper for all global setters

Removes the grandfathered exceptions section from the Public Settings
Pattern docs. Both names that were allowlisted in the initial commit of
this PR were introduced after the policy itself was being defined, so
neither was historically grandfathered:

- `fl::set_rgbw_colorimetric_profile` is already wrapped on `CFastLED`
  (`CFastLED::setRgbwColorimetricProfile`) in this PR, so it no longer
  needs an exception.
- `fl::set_input_gamut` (#2710) is introduced in PR #2711 without a
  `CFastLED` wrapper. The wrapper must be added before that PR merges.

Updated files:
- `.coderabbit.yaml`
- `agents/docs/cpp-standards.md`
- `.claude/agents/architecture-reviewer-agent.md`
- `.claude/commands/code_review.md`

Addresses CodeRabbit review on PR #2715.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* feat(lint): enforce Public Settings Pattern for fl:: global setters (layer 5) (#2716)

* feat(lint): enforce Public Settings Pattern for fl:: global setters

Adds `PublicSettingsPatternChecker` (ci/lint_cpp/public_settings_pattern_checker.py)
— layer 5 of the six-layer Public Settings Pattern enforcement plan introduced
in PR #2715 / docs commit d51a8f6.

What it checks:
  Every public free function declared at `namespace fl` root scope in
  `src/fl/**/*.h` whose name matches `^(set|enable|disable|use)_[a-z]`
  MUST have a matching `CFastLED::setX()` / `enableX()` / `disableX()`
  wrapper in `src/FastLED.h` that delegates to it.

Carve-outs (NOT flagged):
  - Sub-namespaces (fl::detail::, fl::isr::, fl::colorimetric_detail::, …)
  - Anonymous namespaces
  - Class/struct member functions (per-object setters)
  - Function-pointer installers (set_rgb_2_rgbw_function, set_rgb_2_rgbww_function)
  - Per-object mutators: non-const ptr/ref to user-defined type as first param
  - Lines suppressed with `// nolint` or `// ok public_settings`

Grandfathered allowlist (pre-rule offenders, not flagged):
  set_rgbw_colorimetric_profile, set_input_gamut (from #2715 description),
  enable_rgbw_colorimetric_lut, disable_rgbw_colorimetric_lut (#2545),
  set_rgbww_colorimetric_profile (#2558).

Implementation notes:
  - Uses a per-`{` scope stack (not a simple brace counter) so that enum
    bodies, inline function definitions, and nested namespaces are all tracked
    correctly without false namespace pops.
  - FastLED.h is loaded once at `__init__` time for cross-file wrapper lookup.
  - 63 unit tests; `bash lint --cpp` passes clean on the full codebase.
  - Registered in the `fl` scope in run_all_checkers.py.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(lint): annotate first_param list type in public_settings checker

Pyright (--strict) flagged `first_param` as `list[Unknown]` since it's
initialized as a bare `[]`. The list only ever holds str characters
from iterating `params_raw` (a str), so the annotation is `list[str]`.

Drive-by while reviewing the agent-generated PR #2716.

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

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>

* docs(cpp): align grandfathered allowlist text with checker

CodeRabbit (#2715 thread on agents/docs/cpp-standards.md:262) flagged
that the "No grandfathered offenders" wording contradicted the actual
enforcement state: public_settings_pattern_checker.py still carries a
small GRANDFATHERED_NAMES allowlist for legacy bare setters that have
not yet received CFastLED wrappers (set_input_gamut,
enable_rgbw_colorimetric_lut, disable_rgbw_colorimetric_lut,
set_rgbww_colorimetric_profile).

Reconcile the policy text in cpp-standards.md, architecture-reviewer-
agent.md, and code_review.md to describe the transitional allowlist
explicitly: strict for *new* code, shrinking allowlist for legacy
names, entries removed as wrappers land. The behavior of the rule is
unchanged; only the documentation matches reality now.

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

---------

Co-authored-by: Claude Opus 4.7 (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.

bug(rgbw): default source = Rec709/sRGB silently truncates LED gamut — switch default to native LED primaries + D65

1 participant