Skip to content

feat(FastLED): CFastLED::load + loadChannels + loadScreenMap + FledDispatcher (#3311 PR5) - #3330

Merged
zackees merged 2 commits into
masterfrom
feat/fastled-load-dispatcher-3311
Jun 20, 2026
Merged

zackees merged 2 commits into
masterfrom
feat/fastled-load-dispatcher-3311

Conversation

@zackees

@zackees zackees commented Jun 20, 2026 •

Copy link
Copy Markdown
Member

Summary

PR5 of #3311. Adds the bundle-load surface on CFastLED, with each method in its own TU so the linker tree-shakes them out of sketches that never reference Fled bundles.

New surface on CFastLED

  • void load(const Fled& fled) — composes channels + screenmap + script dispatch
  • void loadChannels(const Fled& fled) — iterates fled.channels() and calls add() per
  • void loadScreenMap(const Fled& fled) — shipped as a stub (FL_WARN_F); the controller-binding policy decision is deferred to a follow-up. The feat(fl/fled): create new fl::Fled bundle subsystem (value + runner + section accessors) under src/fl/fled/ #3311 spec says "broadcasts via EngineEvents::onCanvasUiSet", but onCanvasUiSet needs a CLEDController* and CFastLED::loadScreenMap has no specific controller to bind to. Filed for follow-up.

New singleton

fl::detail::FledDispatcher in src/fl/fled/fled_dispatch.h — holds the default-empty wasmLoader / microPyLoader fl::function slots. fledDispatcher() is a construct-on-first-use accessor — the singleton tree-shakes when no one references it (i.e. enableWasm / enableMicroPy are never called).

Tree-shake plumbing

Follows the existing fl.system.sd pattern:

  • src/fl/fled/load/, load_channels/, load_screen_map/ — one TU each
  • src/fl/build/fl.fled.load+.cpp / fl.fled.load_channels+.cpp / fl.fled.load_screen_map+.cpp — recursive unity entry points
  • ci/lint_cpp_rs/src/checkers/unity_build.rs UNITY_EXPECTED_BUILD_FILES allowlist extended for the three new build files

Forward decl of fl::Fled moved to src/fl/fled/fwd.h so FastLED.h does not have to include fled.h.

Test plan

  • bash test fled --debug — green (1/1 DLL, 6 new cases)
  • bash lint --cpp — green
  • CI matrix

Refs #3311

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added three new API methods to load LED configurations from .fled bundles: load(), loadChannels(), and loadScreenMap().
    • Methods gracefully handle invalid or empty bundles without crashing.
  • Tests

    • Added comprehensive test coverage for the new bundle loading functionality, including edge cases and null input handling.

…spatcher (#3311 PR5)

PR5 of #3311. Adds the bundle-load surface on CFastLED, with each
method in its own TU so the linker tree-shakes them out of sketches
that never reference Fled bundles.

New surface on CFastLED:
- load(const Fled&)          - composes channels + screenmap + script dispatch
- loadChannels(const Fled&)  - iterates fled.channels() and calls add() per
- loadScreenMap(const Fled&) - shipped as a stub (FL_WARN_F) - the
                                 controller-binding policy decision is
                                 deferred to a follow-up; #3311 spec says
                                 "broadcasts via EngineEvents::onCanvasUiSet"
                                 but onCanvasUiSet needs a CLEDController*
                                 and CFastLED has no specific controller
                                 to bind to.

New singleton: fl::detail::FledDispatcher (in fl/fled/fled_dispatch.h)
holds the default-empty wasmLoader / microPyLoader fl::function slots.
fledDispatcher() is a construct-on-first-use accessor - the singleton
tree-shakes when no one references it (i.e. enableWasm / enableMicroPy
are never called).

Tree-shake plumbing follows the existing fl.system.sd pattern:
- src/fl/fled/load/, load_channels/, load_screen_map/ - one TU each
- src/fl/build/fl.fled.load+.cpp / fl.fled.load_channels+.cpp /
  fl.fled.load_screen_map+.cpp - recursive unity entry points
- ci/lint_cpp_rs/src/checkers/unity_build.rs UNITY_EXPECTED_BUILD_FILES
  allowlist extended for the three new build files

Forward decl of fl::Fled moved to src/fl/fled/fwd.h so FastLED.h does not
have to include fled.h.

Tests: 6 cases in tests/fl/fled/fled_load.cpp - null Fled is no-op for
each method, valid-but-empty bundle is no-op, FledDispatcher singleton
accessor returns the same object on repeated calls.

Refs #3311 (this is the fifth of seven planned PRs)

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

coderabbitai Bot commented Jun 20, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9ec61921-2097-4675-9ad9-fbf6c6884d3d

📥 Commits

Reviewing files that changed from the base of the PR and between 3ef7ba9 and c3ccacc.

📒 Files selected for processing (2)
  • src/fl/fled/load/fastled_load.cpp.hpp
  • tests/fl/fled/fled_load.cpp

📝 Walkthrough

Walkthrough

Adds three new CFastLED public methods — load, loadChannels, and loadScreenMap — each in its own linker-droppable unity-build translation unit under src/fl/build/. Introduces fl/fled/fwd.h for a lightweight forward declaration of fl::Fled. The loadChannels implementation wires strips via FastLED.add(), while loadScreenMap is a stub. Tests cover null-input no-ops and valid envelope-only bundle loading.

Changes

.fled Bundle Load API

Layer / File(s) Summary
fl::Fled forward declaration and CFastLED public API
src/fl/fled/fwd.h, src/FastLED.h
Introduces fwd.h with namespace fl { class Fled; }, includes it in FastLED.h, and declares load(fled), loadChannels(fled), and loadScreenMap(fled) as public CFastLED methods with documented no-op behavior for falsy inputs.
loadChannels() implementation and unity-build wiring
src/fl/fled/load_channels/fastled_load_channels.cpp.hpp, src/fl/fled/load_channels/_build.cpp.hpp, src/fl/build/fl.fled.load_channels+.cpp
Implements CFastLED::loadChannels to fetch MultiChannelConfig from the bundle and call FastLED.add(*cfg) for each non-null entry; aggregated through _build.cpp.hpp into the linker-droppable translation unit.
loadScreenMap() stub and unity-build wiring
src/fl/fled/load_screen_map/fastled_load_screen_map.cpp.hpp, src/fl/fled/load_screen_map/_build.cpp.hpp, src/fl/build/fl.fled.load_screen_map+.cpp
Implements CFastLED::loadScreenMap as a stub that early-returns on a null ScreenMap and otherwise emits FL_WARN_F; wired into its own linker-droppable translation unit.
load() orchestrator and unity-build wiring
src/fl/fled/load/fastled_load.cpp.hpp, src/fl/fled/load/_build.cpp.hpp, src/fl/build/fl.fled.load+.cpp
Implements CFastLED::load to early-return on a falsy Fled, then call loadChannels and loadScreenMap sequentially; no script-runtime dispatch in this TU.
Tests and CI unity-build validation
tests/fl/fled/fled_load.cpp, ci/lint_cpp_rs/src/checkers/unity_build.rs
Adds tests for null-input no-op behavior and envelope-only bundle loading for all three entry points; registers fl.fled.load+.cpp, fl.fled.load_channels+.cpp, and fl.fled.load_screen_map+.cpp in UNITY_EXPECTED_BUILD_FILES.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#3323: Introduces the fl::Fled PIMPL-based loader and fl.fled+.cpp unity integration that this PR's load/loadChannels/loadScreenMap entry points depend on.
  • FastLED/FastLED#3326: Implements fl::Fled::channels() and fl::Fled::screenMap() typed accessors that CFastLED::loadChannels and CFastLED::loadScreenMap call directly in this PR.

Poem

🐇 Hop hop, the .fled files load with care,
Three new methods now bloom in the FastLED lair!
loadChannels wires strips with a gentle add,
loadScreenMap stubs along (not quite clad),
And load ties them together, neat as a bow —
No crash on null inputs, what a fine show!
The linker drops what's unused — off to burrow we go! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% 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 accurately describes the main change: adding three new public methods (load, loadChannels, loadScreenMap) to CFastLED for bundle loading, which is the primary objective of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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/fastled-load-dispatcher-3311

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 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

🧹 Nitpick comments (1)
src/fl/fled/load_screen_map/fastled_load_screen_map.cpp.hpp (1)

32-32: ⚡ Quick win

Use stream-style warning macro here instead of FL_WARN_F.

This line uses the printf-style warning path; project standards require stream-style FL_WARN(...)/FL_DBG(...) usage in C++ sources.

As per coding guidelines, "Warning/debug output: use FL_WARN(...) / FL_DBG(...) ... warning macros are stream-style (<<), not printf-style."

🤖 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/fled/load_screen_map/fastled_load_screen_map.cpp.hpp` at line 32, The
warning message in the CFastLED::loadScreenMap function uses the printf-style
macro FL_WARN_F, but project coding standards require stream-style warning
macros. Replace FL_WARN_F with FL_WARN and convert the printf-style format
string to stream-style syntax using the << operator to concatenate the warning
message about the stub implementation.

Source: Coding guidelines

🤖 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/fled/load/fastled_load.cpp.hpp`:
- Around line 35-51: The current if-else if chain handling script kinds
(fl::ScriptKind::Wasm and fl::ScriptKind::MicroPy) does not handle the case
where script->kind is neither of these supported types, causing silent failures.
Add a final else clause after the else if block for MicroPy that logs an error
message using FL_ERROR_F indicating that the script kind is unsupported or
unknown. This will ensure that bundle failures with unrecognized script kinds
are properly diagnosable rather than silently no-opping.

---

Nitpick comments:
In `@src/fl/fled/load_screen_map/fastled_load_screen_map.cpp.hpp`:
- Line 32: The warning message in the CFastLED::loadScreenMap function uses the
printf-style macro FL_WARN_F, but project coding standards require stream-style
warning macros. Replace FL_WARN_F with FL_WARN and convert the printf-style
format string to stream-style syntax using the << operator to concatenate the
warning message about the stub implementation.
🪄 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: bb20b015-fbfe-48db-8394-d70e76cd0571

📥 Commits

Reviewing files that changed from the base of the PR and between 91a11f6 and 3ef7ba9.

📒 Files selected for processing (16)
  • ci/lint_cpp_rs/src/checkers/unity_build.rs
  • src/FastLED.h
  • src/fl/build/fl.fled.load+.cpp
  • src/fl/build/fl.fled.load_channels+.cpp
  • src/fl/build/fl.fled.load_screen_map+.cpp
  • src/fl/fled/_build.cpp.hpp
  • src/fl/fled/fled_dispatch.cpp.hpp
  • src/fl/fled/fled_dispatch.h
  • src/fl/fled/fwd.h
  • src/fl/fled/load/_build.cpp.hpp
  • src/fl/fled/load/fastled_load.cpp.hpp
  • src/fl/fled/load_channels/_build.cpp.hpp
  • src/fl/fled/load_channels/fastled_load_channels.cpp.hpp
  • src/fl/fled/load_screen_map/_build.cpp.hpp
  • src/fl/fled/load_screen_map/fastled_load_screen_map.cpp.hpp
  • tests/fl/fled/fled_load.cpp

Comment thread src/fl/fled/load/fastled_load.cpp.hpp Resolved
)

Per follow-up direction: wasm/micropy script-host runtimes are
design-only for v1, not shipped. That makes the FledDispatcher
singleton + the script-dispatch block in CFastLED::load dead code
today, so removing both:

- Delete src/fl/fled/fled_dispatch.h
- Delete src/fl/fled/fled_dispatch.cpp.hpp
- Drop its include from src/fl/fled/_build.cpp.hpp
- Strip the script-dispatch block from src/fl/fled/load/fastled_load.cpp.hpp
  - load() is now just: if (!fled) return; loadChannels(fled); loadScreenMap(fled);
- Drop the dispatcher test case + fled_dispatch.h include from
  tests/fl/fled/fled_load.cpp.

fl::FledScript (the passive data wrapper from PR2) and fl::Fled::script()
stay - they are forward-looking section accessors for the v2 bundle
format and have no runtime cost when no bundle ever carries a script
section (which is always today, since v1 bundles do not).

Refs #3311 #3330

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit 0700dc3 into master Jun 20, 2026
12 of 13 checks passed
@zackees
zackees deleted the feat/fastled-load-dispatcher-3311 branch June 20, 2026 07:33
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant