You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(channels): bind every constant typed chipset to its one encoder (#5162) - #5413
#5163 bound the pixel encoder at the typed add<Bus>() boundary, but only for WS2812. Every other constant chipset (TM1812, TM1908, UCS7604 and all SpiChipsetConfig chipsets) still fell back to the shared selector, which links every encoder. This PR extends #5163's mechanism to all of them, so a typed add<Bus>() with a constant chipset links only its own encoder.
How
EncoderAvailability gets one out-of-line getter per encoder (apa102(), ucs7604(), ...). Each getter references only its own encoder and returns nullptr when the library disables it. FASTLED_DISABLE_UCS7604 / FASTLED_DISABLE_SPI_CHIPSETS therefore stay library-only decisions, which keeps the ODR fix from Channels API: cut add<Bus>() flash overhead vs addLeds<> by 50% (ESP32-C6: +47 KB) #5157.
The chipset-to-encoder mapping lives in one inline EncoderAvailability::dispatch<Binder>() template. The erased path's select() uses it with a binder that calls the getter. TypedChannel::factoryFor() uses it with a binder that returns &createBound<getter>. A constant chipset folds to one factory, and an unknown chipset falls back to the shared selector, as before.
The isWS2812 special case is gone. WS2812 now takes the same path as the other chipsets.
No changes to channel.cpp.hpp or to any encoding loop.
C add<Bus::AUTO>(makeClockless<TIMING_UCS7604_800KHZ>)
390,560 / 18,830
383,732 / 18,830
UCS7604 C - A
+23,964
+17,136 (-28.5%)
C add<Bus::AUTO>(WS2812)
378,240 / 18,775
378,312 / 18,775 (+72)
Linked Channel::encode* symbols, from the bloat report.json:
master, APA102 C and UCS7604 C: all 14 encoders.
this PR, APA102 C: encodeAPA102 only. UCS7604 C: encodeUCS7604 only.
The sketches are scratch copies outside examples/, built in git archive trees of master and of this branch.
Tests
RED first: the new [#5162] constant typed chipsets bind only their own encoder case in tests/unit/fl/channels/encoder_availability.cpp failed on master. Every non-WS2812 chipset resolved to the shared selector. The case checks, for every clockless encoder and all 16 SPI chipsets, that factoryFor() is not the shared selector, that chipsets sharing an encoder share a factory (the APA102/DotStar/HD107 and SK9822 families, the three UCS7604 modes), and that distinct encoders get distinct factories. It also checks that the ChipsetVariant overload used by add<B>(ChannelConfig) agrees.
bash test encoder_availability and bash test fl_channels_channel, quick and --debug: pass.
bash test --cpp: 375/375 unit and 97/97 examples pass. bash lint: pass.
Limitations
The typed WS2812 path costs +72 B: the factory now calls a one-instruction library getter instead of loading the encoder address inline.
When the chipset is not a compile-time constant on the typed path, the inlined mapping keeps all bound factories (one small thunk per encoder). The erased add(cfg) path is unchanged.
Summary by CodeRabbit
Improvements
LED chipset configurations now resolve more consistently to their matching encoder implementations across clockless and SPI-based options.
Chipsets that share an encoder continue to use the same implementation, while distinct encoders remain separately selectable.
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
Parsing warnings: 1
Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks"
If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
No actionable comments were generated in the recent review.
Walkthrough
Typed channel factory selection now uses chipset dispatch to bind factories to encoder-specific implementations. EncoderAvailability provides getter functions and dispatch mappings for clockless and SPI chipsets. Tests verify factory resolution and sharing across typed and erased configurations.
EncoderAvailability declares encoder getters and dispatches clockless and SPI chipset configurations to the matching getter. ChipsetVariant dispatch forwards supported types and returns none for unmatched types. Getter definitions return encoder pointers, or null when the relevant optional encoder is disabled.
TypedChannel uses dispatch to bind a factory to the selected encoder, or falls back to the shared selector when dispatch returns none. Tests check typed and erased resolution and factory sharing across encoder groups.
FastLED/FastLED#5163 — This PR extends the typed factory encoder binding introduced for WS2812 to other constant chipsets.
Merge Risk: Minimal · up to 1662c
Typed add() calls now bind each constant chipset to its own encoder, which should reduce binary size for those sketches. No concrete merge-blocking risk was found in the review.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Linked Issues check
[#5162] The design meets the issue requirements. EncoderAvailability (src/fl/channels/encoder_availability.h) declares one out-of-line getter per encoder: ws2812(), tm1812(), tm1908(), ucs7604(), ap…
Confirm that the head compiles. Either show the definition of FL_ALWAYS_INLINE, or provide a successful build log for src/fl/channels/channel_typed.h and tests/unit/fl/channels/encoder_availability.cpp at the reviewed head. If FL_ALWAYS_INL…
Passed checks: 3 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: it binds each constant typed chipset to its own encoder, which matches the summary (typed factoryFor dispatch, per-encoder getters, new test). The title is a conventio…
Out of Scope Changes check
All changes map to the scope of #5162. The edits are in src/fl/channels/channel_typed.h (factoryFor now calls the shared dispatch), src/fl/channels/encoder_availability.h and encoder_availability.cpp.…
Full details: Title check
Explanation
The title names the main change: it binds each constant typed chipset to its own encoder, which matches the summary (typed factoryFor dispatch, per-encoder getters, new test). The title is a conventional-commit style line with a perf scope and an issue reference (#5162). The objectives cite PR #5413 while the title cites #5162, a numbering mismatch that does not affect relevance. The title is 76 characters, within a reasonable length for a title.
Full details: Out of Scope Changes check
Explanation
All changes map to the scope of #5162. The edits are in src/fl/channels/channel_typed.h (factoryFor now calls the shared dispatch), src/fl/channels/encoder_availability.h and encoder_availability.cpp.hpp (per-encoder getters, dispatch, and removal of isWS2812 overloads), and tests/unit/fl/channels/encoder_availability.cpp (new [#5162] test). The PR description states that channel.cpp.hpp and the encoding loops are unchanged. The removed isWS2812 helpers exist only for the WS2812 special case that the issue asks to generalize. The changes keep FASTLED_DISABLE_* decisions in the library, as the issue requires. No unrelated functional change was identified in the summary.
Full details: Linked Issues check
Explanation
[#5162] The design meets the issue requirements. EncoderAvailability (src/fl/channels/encoder_availability.h) declares one out-of-line getter per encoder: ws2812(), tm1812(), tm1908(), ucs7604(), apa102(), sk9822(), ws2801(), ws2803(), p9813(), lpd8806(), lpd6803(), sm16716(), my9221(), hd108(). A single inline dispatch<Binder>() maps every ClocklessChipset encoder, all SpiChipset values, and ChipsetVariant to its getter. Unknown values return Binder::none(). TypedChannel::factoryFor() (src/fl/channels/channel_typed.h) uses this dispatch, so the WS2812 special case is gone. Availability stays library-owned because the header declarations do not depend on FASTLED_DISABLE_* macros.
Open defect: FactoryBinder in channel_typed.h declares bind<Get>() and none() as non-static member functions. dispatch<Binder>() calls them as Binder::template bind<...>() and Binder::none() with no object. As read, this is ill-formed C++ and would not compile. The read did not show the definition of FL_ALWAYS_INLINE (src/fl/stl/compiler_control.h was truncated before it), so this cannot be fully ruled out. The PR reports passing builds and tests, which conflicts with this reading. Behavioral parity of the bound factories and the link-size results could not be verified from source.
Resolution
Confirm that the head compiles. Either show the definition of FL_ALWAYS_INLINE, or provide a successful build log for src/fl/channels/channel_typed.h and tests/unit/fl/channels/encoder_availability.cpp at the reviewed head. If FL_ALWAYS_INLINE does not make these members static, the binder members in FactoryBinder must be declared static for dispatch() to compile. Also provide the bloat report.json or equivalent link evidence for the APA102 and UCS7604 typed sketches, if the size claims need verification.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Reviewing files that changed from the base of the PR and between 5159f1b and 1662c12.
Files selected for processing: 4
src/fl/channels/channel_typed.h
src/fl/channels/encoder_availability.cpp.hpp
src/fl/channels/encoder_availability.h
tests/unit/fl/channels/encoder_availability.cpp
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.
github-actionsBot
added
sanitized
Title, body and conversation screened; review text requires separate screening.
and removed
sanitized
Title, body and conversation screened; review text requires separate screening.
labels
Nov 22, 2026
Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red ↑ is larger, green ↓ is smaller, Same is unchanged).
Target
FLASH [bytes]
RAM [bytes]
attiny85
2,460 (Same)
136 (Same)
github-actionsBot
added
sanitized
Title, body and conversation screened; review text requires separate screening.
and removed
sanitized
Title, body and conversation screened; review text requires separate screening.
labels
Nov 22, 2026
github-actionsBot
added
sanitized
Title, body and conversation screened; review text requires separate screening.
and removed
sanitized
Title, body and conversation screened; review text requires separate screening.
labels
Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sanitizedTitle, body and conversation screened; review text requires separate screening.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5162
Summary
#5163 bound the pixel encoder at the typed
add<Bus>()boundary, but only for WS2812. Every other constant chipset (TM1812, TM1908, UCS7604 and allSpiChipsetConfigchipsets) still fell back to the shared selector, which links every encoder. This PR extends #5163's mechanism to all of them, so a typedadd<Bus>()with a constant chipset links only its own encoder.How
EncoderAvailabilitygets one out-of-line getter per encoder (apa102(),ucs7604(), ...). Each getter references only its own encoder and returnsnullptrwhen the library disables it.FASTLED_DISABLE_UCS7604/FASTLED_DISABLE_SPI_CHIPSETStherefore stay library-only decisions, which keeps the ODR fix from Channels API: cut add<Bus>() flash overhead vs addLeds<> by 50% (ESP32-C6: +47 KB) #5157.EncoderAvailability::dispatch<Binder>()template. The erased path'sselect()uses it with a binder that calls the getter.TypedChannel::factoryFor()uses it with a binder that returns&createBound<getter>. A constant chipset folds to one factory, and an unknown chipset falls back to the shared selector, as before.isWS2812special case is gone. WS2812 now takes the same path as the other chipsets.channel.cpp.hppor to any encoding loop.ESP32-C6 flash (
bash bloat esp32c6 --build, image flash / attributed RAM)addLeds<APA102, 3, 4, BGR>add<Bus::AUTO, SpiChipsetConfig>(apa102)addLeds<UCS7604HD, 3, GRB>add<Bus::AUTO>(makeClockless<TIMING_UCS7604_800KHZ>)add<Bus::AUTO>(WS2812)Linked
Channel::encode*symbols, from the bloatreport.json:encodeAPA102only. UCS7604 C:encodeUCS7604only.The sketches are scratch copies outside
examples/, built ingit archivetrees of master and of this branch.Tests
[#5162] constant typed chipsets bind only their own encodercase intests/unit/fl/channels/encoder_availability.cppfailed on master. Every non-WS2812 chipset resolved to the shared selector. The case checks, for every clockless encoder and all 16 SPI chipsets, thatfactoryFor()is not the shared selector, that chipsets sharing an encoder share a factory (the APA102/DotStar/HD107 and SK9822 families, the three UCS7604 modes), and that distinct encoders get distinct factories. It also checks that theChipsetVariantoverload used byadd<B>(ChannelConfig)agrees.channel.cpp: every clockless encoder and all 16 SPI variants, typed vs erased) and the conflicting-macro availability test now run through the new bound factories.bash test encoder_availabilityandbash test fl_channels_channel, quick and--debug: pass.bash test --cpp: 375/375 unit and 97/97 examples pass.bash lint: pass.Limitations
add(cfg)path is unchanged.Summary by CodeRabbit