Repository navigation
feat(channels): runtime FastLED.add(fl::Bus, cfg) dispatch (closes #2453) - #2454
Conversation
) Sister API to the templated FastLED.add<fl::Bus B>(cfg) from #2451. The templated form ODR-uses BusTraits<B>::instancePtr() at the call site to link the named driver — that is the binary-bloat fix from #2420/#2421. But that mode is wrong for sketches that have already called fl::enableAllDrivers() and want runtime dispatch by enum without the per- call-site linker keep-alive. The new non-template overload: FastLED.add(fl::Bus::RMT, cfg); - Sets cfg.options.mAffinity = fl::busName(b) so ChannelManager dispatches by name (matches each driver's getName() exactly via the bus.h table). - Maps fl::Bus::AUTO to "clear affinity" so the manager falls back to priority dispatch — same contract as not setting an affinity at all. - Does NOT name BusTraits<B>::instance, so the driver TU is only linked when something else in the build named it (enableAllDrivers, the templated form, or a per-driver bus_traits.h include + enableDrivers). Tests cover: - Runtime dispatch lands on the named driver (Bus::STUB on host). - Overload overwrites prior mAffinity strings. - Bus::AUTO clears affinity and falls through to priority dispatch. 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 (2)
📝 WalkthroughWalkthroughA new ChangesRuntime Bus Dispatch API
🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Summary
Closes #2453. Adds the missing runtime counterpart to the templated `FastLED.add<fl::Bus B>(cfg)` form from #2451:
```cpp
#include "fl/channels/all_drivers.h"
void setup() {
FastLED.enableAllDrivers(); // PR #2448
FastLED.add(fl::Bus::RMT, cfg); // ← new: runtime dispatch by enum
}
```
What changed
Why this preserves the binary-bloat fix
The implementation deliberately does not name `BusTraits::instance()` or `instancePtr()`. That means this overload contributes zero per-call-site linker keep-alive. Sketches that don't otherwise reference a bus's traits still let `--gc-sections` drop the driver — the binary-bloat fix from #2420 / #2421 is preserved end to end.
The driver gets linked only if something else in the build names that bus:
Tests
Three new host-side cases in `tests/fl/channels/channel.cpp`:
Test plan
Reviewer
Code-reviewed by the c-cpp-expert-agent before commit. Verified:
Related
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests