Skip to content

Add RGBW colorimetric codec profile API - #3435

Merged
zackees merged 4 commits into
masterfrom
codex/rgbw-colorimetric-codec
Jun 28, 2026
Merged

zackees merged 4 commits into
masterfrom
codex/rgbw-colorimetric-codec

Conversation

@zackees

@zackees zackees commented Jun 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add src/fl/color/rgbw.h as the public fl::color::* facade for RGBW colorimetric profile APIs.
  • Use explicit fl::shared_ptr<const fl::color::DiodeProfile> in the RGBW examples instead of the removed DiodeProfilePtrConst alias.
  • Let fl::Rgbw carry an owned immutable profile directly, and warm the colorimetric cache from setRgbw(...) before the hot pixel path uses it.
  • Add the colorimetric strategy harness, vendored verifier fixture, and fixture-generation tooling so memory, CPU, and max-channel LSB accuracy tradeoffs are visible.
  • Fix the unit-test CI lint gate by building fastled-lint with soldr --no-cache cargo build, avoiding the hosted-runner zccache protocol mismatch, and update the ESP32-S3 bloat baseline for the intentional size change.

Attribution

Thanks to sonia (@JChalka) for originating the RGBW colorimetric work, the math-model discussion, verifier material, and roadmap that shaped this API and the strategy harness.

Example sketch:
https://github.com/FastLED/FastLED/blob/codex/rgbw-colorimetric-codec/examples/RGBWColorimetric/RGBWColorimetric.ino

Verification

  • bash test fastled_core --cpp --verbose --no-fingerprint --clean
  • bash test rgbw_colorimetric --cpp --verbose --no-fingerprint
  • bash test colorimetric_strategy_table --cpp --verbose --no-fingerprint
  • bash test --examples RGBW --verbose --no-fingerprint --clean
  • bash test --examples RGBWColorimetric --verbose --no-fingerprint --clean
  • bash lint --cpp --no-fingerprint src/fl/gfx/rgbw.h src/fl/gfx/rgbw.cpp.hpp src/fl/color/rgbw.h src/FastLED.h examples/RGBW/RGBW.ino examples/RGBWColorimetric/RGBWColorimetric.ino tests/fastled_core.cpp tests/fl/gfx/rgbw_colorimetric.cpp tests/misc/colorimetric_strategy_table.cpp
  • soldr --no-cache cargo build --manifest-path ci/lint_cpp_rs/Cargo.toml --bin fastled-lint
  • python -m py_compile ci/lint_cpp/rust_binary_cache.py
  • git diff --check

Closes #2748.
Closes #3231.
Closes #3242.
Closes #3255.
Closes #3422.
Closes #3429.

Summary by CodeRabbit

  • New Features

    • Added RGBW colorimetric support with configurable profile handling and new example sketches, including a dedicated RGBW colorimetric demo.
    • Added a shared colorimetric test harness and generated fixtures to support broader validation coverage.
  • Bug Fixes

    • Improved RGBW behavior across builds and platforms, including better native pin support handling and more stable cache behavior on hosted runners.
    • Updated RGBW processing to preserve expected output behavior with profile-aware configuration.
  • Documentation

    • Expanded fixture and RGBW usage docs to better explain the new colorimetric workflow.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 53bcbd87-ddc4-4084-a476-d07664695e4a

📥 Commits

Reviewing files that changed from the base of the PR and between c5ee1ad and 12892e6.

⛔ Files ignored due to path filters (1)
  • tests/misc/golden/verifier_known_bad.csv is excluded by !**/*.csv
📒 Files selected for processing (24)
  • ci/lint_cpp/rust_binary_cache.py
  • ci/meson/native/meson.build
  • ci/tools/extract_verifier_fixture.py
  • ci/tools/gen_colorimetric_fixture_header.py
  • examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp
  • examples/AutoResearch/AutoResearchTimingDrift.h
  • examples/AutoResearch/LegacyClocklessProxy.h
  • examples/RGBW/RGBW.ino
  • examples/RGBWColorimetric/RGBWColorimetric.ino
  • src/FastLED.h
  • src/fl/channels/cled_controller.h
  • src/fl/channels/options.h
  • src/fl/chipsets/encoders/pixel_iterator.h
  • src/fl/color/rgbw.h
  • src/fl/gfx/rgbw.cpp.hpp
  • src/fl/gfx/rgbw.h
  • src/pixel_controller.h
  • tests/data/esp32s3_bloat_baseline.txt
  • tests/fastled_core.cpp
  • tests/fl/gfx/rgbw_colorimetric.cpp
  • tests/misc/colorimetric_strategy_harness.hpp
  • tests/misc/colorimetric_strategy_table.cpp
  • tests/misc/golden/README.md
  • tests/misc/golden/verifier_known_bad.hpp

📝 Walkthrough

Walkthrough

This PR refactors the RGBW colorimetric solver to carry a per-instance shared_ptr<const DiodeProfile> inside fl::Rgbw, keying cache/LUT rebuilds off that profile pointer rather than a global singleton. It adds make_diode_profile overloads, prepare_rgbw_colorimetric, and a new const Rgbw&-based dispatch signature propagated through all call sites. Golden fixture tooling (CSV extractor, HPP generator, verifier_known_bad.hpp) and a colorimetric strategy evaluation harness are added. A new RGBWColorimetric example is included. AutoResearch pin 22 instantiation is conditionally gated to Teensy 4.x.

Changes

RGBW Colorimetric Per-Profile Ownership Refactor

Layer / File(s) Summary
Rgbw struct, solver API, and facade header
src/fl/gfx/rgbw.h, src/fl/color/rgbw.h, src/FastLED.h, src/fl/channels/options.h
fl::Rgbw gains a shared_ptr<const DiodeProfile> profile field and new constructors. make_diode_profile overloads, prepare_rgbw_colorimetric, and const Rgbw&-based solver/dispatcher overloads are declared. rgb_2_rgbw's old (RGBW_MODE, u16) dispatcher overload is removed. CFastLED::setInputGamut overloads are removed. A new fl::color::rgbw.h facade re-exports profile APIs.
Colorimetric solver: per-profile cache, LUT rebuild, and dispatch
src/fl/gfx/rgbw.cpp.hpp
Adds resolve_rgbw_profile and profile-keyed get_cache/rebuild_lut_if_stale overloads. Implements prepare_rgbw_colorimetric. Rewires rgb_2_rgbw_colorimetric LUT fast path to select ProfileCache via cfg.profile. Adds a native-subgamut analytical guard that can bypass the LUT. Updates boosted path cache key. Adds disabled-colorimetric branch stubs.
Call-site wiring: const Rgbw& propagation
src/fl/channels/cled_controller.h, src/fl/chipsets/encoders/pixel_iterator.h, src/pixel_controller.h
CLEDController::setRgbw calls prepare_rgbw_colorimetric before storing. All loadAndScaleRGBW/set_rgbw/vtable/function-pointer signatures changed from Rgbw by value to const Rgbw&. PixelController::loadAndScaleRGBW passes the full rgbw object to rgb_2_rgbw.
Golden fixture tooling and data
ci/tools/extract_verifier_fixture.py, ci/tools/gen_colorimetric_fixture_header.py, tests/misc/golden/verifier_known_bad.hpp, tests/misc/golden/README.md
extract_verifier_fixture.py converts the JChalka verifier CSV into a normalized golden CSV. gen_colorimetric_fixture_header.py regenerates verifier_known_bad.hpp from that CSV. The generated header defines VerifierRow, kVerifierRows[], and kVerifierRowCount in fl::colorimetric_test::fixture. README documents the schema, provenance, and regeneration commands.
Colorimetric strategy evaluation harness
tests/misc/colorimetric_strategy_harness.hpp
Adds Strategy/Budget/ErrorStats types, XYZ/Lab conversion helpers, ΔE and LSB delta computation, RGBWW interpolation, evaluate_strategy/evaluate_strategy_pair_lsb/evaluate_strategy_cube_lsb runners, and stats_within_budget.
Tests, examples, CI defines, and bloat baseline
tests/fl/gfx/rgbw_colorimetric.cpp, tests/fastled_core.cpp, examples/RGBWColorimetric/RGBWColorimetric.ino, examples/RGBW/RGBW.ino, ci/meson/native/meson.build, tests/data/esp32s3_bloat_baseline.txt
New RGBWColorimetric sketch. RGBW example updated to use kRGBWColorimetric mode with explicit diode profile. New public-API-level colorimetric dispatch test. LUT error-floor and native topology test thresholds relaxed. New LUT native topology regression test (#3422). applyConfig test extended to verify profile propagation. FASTLED_RGBW_COLORIMETRIC=1 added to native meson build. ESP32-S3 bloat baseline bumped to 339172.

AutoResearch Pin 22 Guard and CI Cache Fix

Layer / File(s) Summary
AutoResearch pin 22 conditional compilation
examples/AutoResearch/LegacyClocklessProxy.h, examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp, examples/AutoResearch/AutoResearchTimingDrift.h
Introduces AUTORESEARCH_LEGACY_SUPPORTS_PIN_22 macro (1 on FL_IS_TEENSY_4X, 0 otherwise). Gates case 22 in LegacyClocklessProxy::switch(pin) behind it. Updates the LegacyApiPinRange error message and DriftResult::valid_pin comment accordingly.
Soldr build --no-cache flag
ci/lint_cpp/rust_binary_cache.py
Adds --no-cache to the soldr cargo build command in _run_build and updates the docstring.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • FastLED/FastLED#2552: The per-profile get_cache/LUT rebuild infrastructure in rgbw.cpp.hpp directly extends the colorimetric/LUT solver introduced there.
  • FastLED/FastLED#2560: Both PRs modify CLEDController::setRgbw in src/fl/channels/cled_controller.h—this PR adds the prepare_rgbw_colorimetric call inside the same branch that PR #2560 refactored.
  • FastLED/FastLED#2721: Both PRs touch the LUT interpolation choice and error-floor test assertions in rgbw_colorimetric.cpp.

Poem

🐇 Hoppity-hop through the color space,
A profile per strip, each in its place!
The cache now keys on the pointer you give,
So cyan stays cyan, and green gets to live.
No global gamut to muddle the hue—
Each LED controller knows just what to do! 🌈

✨ 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 codex/rgbw-colorimetric-codec

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.

@zackees
zackees marked this pull request as ready for review June 28, 2026 04:23
@zackees
zackees merged commit f9209e5 into master Jun 28, 2026
9 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from In Progress to Triage in FastLED Tracker Jun 28, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 28, 2026
@zackees
zackees deleted the codex/rgbw-colorimetric-codec branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment