Repository navigation
feat(channels): addLeds<..., fl::Bus B> trailing parameter (closes #2460) - #2465
Conversation
) Adds an optional trailing `fl::Bus B = fl::Bus::AUTO` template parameter to every `FastLED.addLeds<>` variant. `B = AUTO` (the default) leaves existing call sites byte-for-byte unchanged; `B != AUTO` ODR-uses `fl::BusTraits<B>::instance` via a new `fl::busKeepAlive<B>()` helper so `--gc-sections` retains the named driver TU. For the `FASTLED_SPI_USES_CHANNEL_API` SPI variants (which already construct a `ChannelConfig`), the body also sets `config.options.mBus = B` so the channel routes through the named driver at runtime. Legacy non-Channel-API controllers keep their platform-default routing and rely on linker keep-alive alone — for full runtime routing through a specific Bus, prefer `FastLED.add(cfg)` with `cfg.options.mBus = B`. The runtime miss diagnostic in `channel.cpp.hpp` now lists three remediations: `fl::enableDrivers<>()`, `FastLED.enableAllDrivers()`, and the new `FastLED.addLeds<..., fl::Bus::X>(...)` shape. Tests cover the helper plus one clockless (WS2812) and one SPI (APA102) variant in `tests/fl/channels/bus_traits.cpp`, with default- AUTO regression guards. Verification: - bash test --cpp: 303/303 host tests pass - bash lint: clean - bash compile uno --examples Blink: AVR C++11 path compiles - ESP32 platform compile blocked by unrelated toolchain cache breakage (missing Arduino.h / WString.h / soc_caps.h in the framework-arduinoespressif32 cache); CHANNEL_API SPI path body change is textually a single-line write to the existing `mBus` field added in #2461 Closes #2460. Refs #2459, #2428. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughExtends all ChangesLegacy Bus pinning for addLeds templates
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Refresh the channels README and one related code docstring against the current API surface (post #2459 / #2460 / #2465): README: - Compile-time bus binding now lists both entry points equally (`fl::TypedChannel<...>::create()` and `addLeds<..., fl::Bus::X>`). The "planned addLeds<..., fl::Bus::X> — see #2460" note is gone: that feature shipped via #2465. - Drop "Backwards Compatible API" framing for `addLeds<>` — both the Channel API and the template `addLeds<>` API are first-class; pick by call-site shape, not by maturity. - Drop "Legacy `addLeds<>` Bus pinning" / "legacy FastLED.addLeds<...> shape" labels — these are the actively-supported entry points. - Expand the Engine Priority table to match `fl/channels/bus_priorities.h` exactly: I2S_SPI / LCD_SPI (10), PARLIO (4), LCD_RGB (3), RMT / LCD_CLOCKLESS (2), I2S / FLEX_IO / OBJECT_FLED (1), SPI / BIT_BANG / STUB (0), UART (-1). Split by platform family (ESP32 / Teensy 4.x / Portable). - Rename "Engine Affinity" section to "Per-Channel Bus Pinning (Mixed- Timing Parallel Output)" — the section was named after the removed string `mAffinity` field. Update internal back-references. - Trim 3.10.3-era "backstory" framing on `enableDrivers<>` / `FASTLED_DISABLE_LEGACY_DRIVER_REGISTRY` — describe what the toggle does today, not what it restores from history. - Update bus-miss diagnostic description to list all three remediations the actual `FL_ERROR` emits (enableDrivers / enableAllDrivers / addLeds<..., fl::Bus::X>). - Reference section: add `fl/channels/bus_priorities.h`, list `busKeepAlive<B>()`, expand the `ChannelManager` method list to include `setDriverPriority` / `setDriverEnabled` / `setExclusiveDriver`. src/fl/channels/channel.h: - `Channel::create()` docstring no longer references the removed `config.affinity` field. Replace with current `cfg.options.mBus` behavior + the showPixels() fallback semantics. No code behavior change. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
fl::Bus B = fl::Bus::AUTOtemplate parameter to everyFastLED.addLeds<>variant; default-AUTO call sites are byte-for-byte unchanged.fl::busKeepAlive<B>()helper (insrc/fl/channels/bus_traits.h) ODR-usesBusTraits<B>::instancewhenB != AUTOso--gc-sectionsretains the named driver TU.FASTLED_SPI_USES_CHANNEL_APISPI variants, the body also setsconfig.options.mBus = Bto pin runtime routing through the named driver.channel.cpp.hppnow lists the third remediation alongsideenableDrivers<>/enableAllDrivers().Issue acceptance criteria (from #2460)
FastLED.addLeds<>variant accepts the trailingfl::Bus B = fl::Bus::AUTOparameter.B = AUTO(the default) leaves existing call sites byte-for-byte unchanged.B != AUTOODR-usesfl::BusTraits<B>::instanceso--gc-sectionskeeps only the named driver TU.channel.cpp.hpplists the newaddLeds<..., fl::Bus::X>(...)remediation.Strategy (hybrid)
FASTLED_SPI_USES_CHANNEL_APIbranch): setcfg.options.mBus = Bto route through the named driver. One-line addition to bodies that already build aChannelConfig.#elsebranch, clockless, FIBCC, OctoWS2811, WS2812Serial, SmartMatrix, Block parallel): emitfl::busKeepAlive<B>()for linker keep-alive only; runtime routing stays on the platform default. This avoids retrofittingsetDriver()into every legacy controller (out-of-scope per the issue's Option B con).Full README walkthrough added to
src/fl/channels/README.mdunder the compile-time bus selection section.Test plan
bash test --cpp— 303/303 host tests pass (covers clockless STUB + legacy SPI body changes via new test cases intests/fl/channels/bus_traits.cpp).bash lint— clean.bash compile uno --examples Blink— AVR C++11 path compiles cleanly (verifies the C++11-compatible struct-specialization helper).framework-arduinoespressif32cache is missingArduino.h/WString.h/soc/soc_caps.h). TheFASTLED_SPI_USES_CHANNEL_APIbody change is a single-line write to themBusfield that has been the canonical field since feat(channels): non-template FastLED.add() + typed mBus + remove mAffinity (closes #2459) #2461; reviewers may want to verify on their own ESP32 setup.Related
4afad42d3f)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
addLeds()API across all controller types to accept an optional bus parameter for explicit hardware bus selection and legacy bus pinning support.Documentation