Repository navigation
Description
Context
After #2451 / #2454 / #2456 landed, the Channel API has three templated entry points doing almost the same job:
| Template | Asserts | Sets affinity | Bus::AUTO allowed? |
|---|---|---|---|
| `Channel::create(ChannelConfig)` (#2451) | `BusSupports<B, ANY>` | yes | no (`static_assert`) |
| `TypedChannel<B, Chipset>::create(ChannelConfigOf)` (#2449) | `BusSupports<B, Chipset>` (stricter) | no | yes (resolves via `DefaultBus`) |
| `FastLED.add(ChannelConfig)` / `FastLED.add<B, Chipset>(ChannelConfigOf)` | forwards | mixed | mixed |
This is a real SSOT violation: each template independently does the `BusTraits::instancePtr()` ODR-use + `static_assert` dance, and they don't even agree on whether `AUTO` is legal or whether the affinity gets set.
Direction
Collapse to a single non-template `FastLED.add(cfg)` user-facing API; move `Bus` selection out of the templates and into the runtime config.
Required changes
-
Bus-typed affinity field. Convert `ChannelOptions::mAffinity` from `fl::string` to `fl::Bus mBus` (default `fl::Bus::AUTO`). This is the Phase 4 cleanup listed in feat(channels): compile-time Bus binding via templated ChannelConfig (eliminates Channel API binary bloat) #2428's "Deletions / simplifications" table.
-
Non-template
FastLED.add(). Remove the templated `FastLED.add(cfg)` and `FastLED.add<B = AUTO, Chipset>(ChannelConfigOf)` overloads. The user-facing surface is just:FastLED.add(cfg); // dispatches by cfg.options.mBus (default AUTO -> priority) FastLED.add(fl::Bus::RMT, cfg); // runtime-Bus convenience (sets cfg.options.mBus then add)
-
Runtime miss diagnostic. If `cfg.options.mBus` names a driver that is NOT in `ChannelManager`'s registered table, emit one-shot `FL_ERROR` listing the missing driver and the remediations:
- `fl::enableDriversfl::Bus::X()` (selective opt-in for one bus)
- `fl::enableAllDrivers()` (every driver on this platform)
- `addLeds<..., fl::Bus::X>(...)` (legacy API; sets the Bus AND triggers linker keep-alive at compile time)
Then default to `AUTO` / priority dispatch. The infrastructure for this already exists from feat(channels): one-shot affinity-miss diagnostic + normalized driver names (closes #2455) #2456; this issue swaps the input from `fl::string` to `fl::Bus` and updates the message.
-
Legacy
addLeds<>Bus support. Add a trailing default template parameter to every `FastLED.addLeds<>` variant:template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO> static ::CLEDController& addLeds(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0); template<template<fl::u8 DATA_PIN, fl::EOrder RGB_ORDER> class CHIPSET, fl::u8 DATA_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO> static ::CLEDController& addLeds(CRGB* data, int nLedsOrOffset, int nLedsIfOffset = 0);
When the user writes `addLeds<WS2812, 4, GRB, fl::Bus::RMT>(leds, n)`, the function sets `cfg.options.mBus = fl::Bus::RMT` AND ODR-uses `BusTraitsfl::Bus::RMT::instancePtr()` inside the body, so the linker keeps the RMT TU. The default `fl::Bus::AUTO` preserves all existing call sites byte-for-byte.
-
Template removals. `Channel::create(ChannelConfig)` and `FastLED.add(...)` go away. `TypedChannel<B, Chipset>::create()` and the new `addLeds<..., fl::Bus B>` trailing parameter become the two remaining compile-time `Bus` entry points.
-
README catch-up. The `src/fl/channels/README.md` examples and the API surface section need a sweep — every `FastLED.addBus::X(cfg)` example must turn into either `FastLED.add(cfg)` with `cfg.options.mBus = fl::Bus::X`, OR `FastLED.add(fl::Bus::X, cfg)`, OR `addLeds<..., fl::Bus::X>(...)`. The dual-mode dispatch section needs rewriting.
Acceptance criteria
- `ChannelOptions::mBus` is `fl::Bus` (not `fl::string`); no remaining `mAffinity` field.
- No templated `FastLED.add<>()` overloads. `FastLED.add(cfg)` and `FastLED.add(fl::Bus, cfg)` are the only public `add` shapes that take a Bus.
- `addLeds<..., fl::Bus B>` exists; default `fl::Bus::AUTO` keeps every existing call site working.
- Calling `FastLED.add(cfg)` with `cfg.options.mBus = fl::Bus::RMT` on a build that hasn't registered RMT prints exactly one `FL_ERROR` with the three remediation options listed above, falls through to priority dispatch.
- README is rewritten to reflect the new single-entry API.
- Full cpp test suite still passes.
Related
- feat(channels): compile-time Bus binding via templated ChannelConfig (eliminates Channel API binary bloat) #2428 — parent meta-issue (Phase 4 conversion of `mAffinity` was always planned here).
- feat(channels): templated Channel::create<Bus B>() / FastLED.add<Bus B>() (#2428, closes #2167) #2451 — templated `FastLED.add()` (this issue undoes that direction).
- feat(channels): runtime FastLED.add(fl::Bus, cfg) dispatch (closes #2453) #2454 — runtime `FastLED.add(Bus, cfg)` (keep this).
- feat(channels): one-shot affinity-miss diagnostic + normalized driver names (closes #2455) #2456 — affinity-miss diagnostic + driver-name normalization (build on this).
- FastLED Channels API #2167 — closed by feat(channels): templated Channel::create<Bus B>() / FastLED.add<Bus B>() (#2428, closes #2167) #2451; the new `addLeds<..., Bus>` shape covers the same "closes FastLED Channels API #2167" use case via legacy syntax.
Activity
feat(channels): non-template FastLED.add() + typed mBus + remove mAff…
feat(channels): addLeds<..., fl::Bus B> trailing parameter (closes #2460
docs(channels): README accuracy sweep + drop legacy framing (#2466)
refactor(channels): typed FastLED.setExclusiveDriver(fl::Bus) + lower…