Skip to content

feat(fl): bidirectional fromFled factories on Video / ScreenMap / MultiChannelConfig (#3311 PR4) - #3328

Merged
zackees merged 1 commit into
masterfrom
feat/fled-from-fled-factories-3311
Jun 20, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/fled-from-fled-factories-3311

Conversation

@zackees

@zackees zackees commented Jun 20, 2026 •

Copy link
Copy Markdown
Member

Summary

PR4 of #3311. Adds the per-type fromFled static factories on the three section types that fl::Fled produces, so call sites can spell either:

auto v = fled.video();                  // fled-side
auto v = fl::Video::fromFled(fled);     // type-side

interchangeably — same data, same return type, same null/empty contract.

Tree-shake

Each factory is a one-line forwarder defined in src/fl/fled/fled.cpp.hpp (the canonical fled TU). The declarations live in the host headers with only a forward decl of fl::Fled, so callers don't pay an extra include cost. The linker resolves the static methods to fled.cpp.hpp's TU, which is only pulled in when something already references the Fled subsystem — sketches that don't use fled see zero size cost.

Stub state today

  • ScreenMap::fromFled returns a real ScreenMap (because PR2's Fled::screenMap() is implemented).
  • Video::fromFled and MultiChannelConfig::fromFled return nullptr (because the matching Fled::video() and Fled::channels() are themselves stubs in PR2; they'll start returning real objects when those accessors are filled in).

Files changed

  • src/fl/fx/video.h — fwd decl + static fromFled declaration
  • src/fl/math/screenmap.h — fwd decl + static fromFled declaration
  • src/fl/channels/config.h — fwd decl + static fromFled declaration on MultiChannelConfig
  • src/fl/fled/fled.cpp.hpp — three one-line bodies
  • tests/fl/fled/fled_from_fled.cpp — new, 3 cases

Test plan

  • bash test fled --debug — green
  • bash lint --cpp — green
  • CI matrix

Refs #3311

🤖 Generated with Claude Code

Summary by CodeRabbit

New Features

  • Added alternative factory methods for Video, ScreenMap, and MultiChannelConfig that allow creating instances directly from Fled bundles.

Tests

  • Added test suite validating the new factory methods handle default, empty, and populated Fled bundle scenarios correctly.

…tiChannelConfig (#3311 PR4)

PR4 of #3311. Adds the per-type fromFled static factories on the three
section types that fled produces, so call sites can spell either:

    auto v = fled.video();                  // fled-side
    auto v = fl::Video::fromFled(fled);     // type-side

interchangeably - same data, same return type, same null/empty contract.

Each factory is a one-line forwarder defined in fl/fled/fled.cpp.hpp
(the canonical fled TU). The declarations live in the host headers
(fl/fx/video.h, fl/math/screenmap.h, fl/channels/config.h) with only a
forward decl of fl::Fled, so callers don't pay an extra include cost.

Tree-shake: linker resolves the static methods to fled.cpp.hpp's TU,
which is only pulled into builds that already reference the Fled
subsystem - sketches that don't use fled see zero size cost.

Video::fromFled and MultiChannelConfig::fromFled return nullptr today
because Fled::video() and Fled::channels() are themselves stubs in PR2;
they'll start returning real objects when those accessors are filled in
(separate scopes). ScreenMap::fromFled works today because PR2 has the
real screenMap() body.

Tests: 3 cases in tests/fl/fled/fled_from_fled.cpp - null Fled returns
null for all three, empty bundle returns null for all three, factory
returns the same pointer as the matching accessor.

Refs #3311 (this is the fourth 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: 7fbcaf45-7060-4ab1-a9be-67fd961f133a

📥 Commits

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

📒 Files selected for processing (5)
  • src/fl/channels/config.h
  • src/fl/fled/fled.cpp.hpp
  • src/fl/fx/video.h
  • src/fl/math/screenmap.h
  • tests/fl/fled/fled_from_fled.cpp

📝 Walkthrough

Walkthrough

Adds bidirectional fromFled(const Fled&) static factory methods to Video, ScreenMap, and MultiChannelConfig. Each method is declared in the respective class header (with a Fled forward declaration), implemented as a one-line forwarder in fled.cpp.hpp delegating to the corresponding Fled accessor, and covered by a new test file.

Changes

Bidirectional fromFled() factory API

Layer / File(s) Summary
fromFled() declarations in class headers
src/fl/fx/video.h, src/fl/math/screenmap.h, src/fl/channels/config.h
Each header gains a class Fled forward declaration and a public static fromFled(const Fled&) method returning fl::shared_ptr<T> with FL_NO_EXCEPT.
fromFled() implementations in fled.cpp.hpp
src/fl/fled/fled.cpp.hpp
Adds #include "fl/channels/config.h" and implements the three one-line forwarders: Video::fromFled → fled.video(), ScreenMap::fromFled → fled.screenMap(), MultiChannelConfig::fromFled → fled.channels().
Tests for null and empty-bundle behavior
tests/fl/fled/fled_from_fled.cpp
New test file with buildEmptyBundle() helper; asserts all three fromFled() calls return nullptr for a default-constructed Fled and for a minimal {} bundle, and confirms pointer identity matches the corresponding Fled accessor results.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • FastLED/FastLED#3323: Introduced the fl::Fled class that this PR extends with fromFled() forwarders in fled.cpp.hpp.
  • FastLED/FastLED#3326: Introduced the typed Fled accessors (Fled::video(), Fled::screenMap(), Fled::channels()) that the new fromFled() factories delegate to directly.

Poem

🐇 Hop, hop, the factory's done,
fromFled and Fled now run as one!
A pointer here, a forwarder there,
nullptr safe beyond compare.
Two paths to the bundle, equal and bright—
the rabbit approves this bidirectional delight! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% 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 and specifically describes the main change: adding bidirectional fromFled factory methods to three types (Video, ScreenMap, MultiChannelConfig). It is clear, concise, and directly reflects the primary objective of the pull request.
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/fled-from-fled-factories-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.

@zackees
zackees merged commit 8ec6583 into master Jun 20, 2026
10 of 11 checks passed
@zackees
zackees deleted the feat/fled-from-fled-factories-3311 branch June 20, 2026 07:31
@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