Skip to content

refactor(channels): typed FastLED.setExclusiveDriver(fl::Bus) + lower string form #2471

Closed

Description

@zackees

Motivation

FastLED.setExclusiveDriver(const char* name) (and the equivalent ChannelManager::setExclusiveDriver(const char*)) is the only string-based knob left on the public driver-selection surface after #2459 / #2460 introduced the typed `fl::Bus` enum. For built-in drivers this is strictly worse than the typed form — `fl::Bus::RTM` is a compile error, `"RTM"` is a silent runtime fall-through.

The string form does have legitimate callers, though, so it can't be removed outright:

  • AutoResearch (4 sites) — driver name comes from RPC/JSON at runtime, can resolve to any registered driver.
  • Mock-test infrastructure (13 sites in `tests/fl/channels/spi_channel.cpp`) — registers custom mock drivers like `MockSpiEngine("MOCK_SPI")` whose names are not in `fl::Bus`.

Both already go through `ChannelManager` directly (`manager.setExclusiveDriver(...)`), not the `FastLED.` facade.

Proposal

Public facade (`FastLED.setExclusiveDriver`):

  • Replace `(const char*)` with `(fl::Bus)`. Typed, typo-safe. This is what 99% of user code should use.

Lower-level (`ChannelManager`):

  • Rename `ChannelManager::setExclusiveDriver(const char*)` → `ChannelManager::setExclusiveDriverByName(const char*)`. Same behavior, name signals "this is the by-name escape hatch — you probably want the typed form."
  • Add `ChannelManager::setExclusiveDriver(fl::Bus)` overload that calls `setExclusiveDriverByName(busName(b))`.

AutoResearch helper (new):

  • New helper in `examples/AutoResearch/` that calls `FastLED.enableAllDrivers()` then `ChannelManager::instance().setExclusiveDriverByName(name)`. AutoResearch's 4 call sites switch to this.

Mock tests:

  • 13 call sites switch from `manager.setExclusiveDriver("MOCK_X")` to `manager.setExclusiveDriverByName("MOCK_X")`.

Net effect

  • `FastLED.setExclusiveDriver()` is typed-only (the public API users see).
  • The string form survives where it's actually needed (mocks + runtime-resolved names), but no longer presents itself as the obvious default — it's relegated to `setExclusiveDriverByName` on `ChannelManager`.
  • Existing string usage migrates mechanically with a rename.

Acceptance criteria

  • `bash test --cpp` passes
  • `bash lint` clean
  • `FastLED.setExclusiveDriver("RMT")` no longer compiles
  • `FastLED.setExclusiveDriver(fl::Bus::RMT)` works
  • `ChannelManager::setExclusiveDriverByName("MOCK_X")` works for mock-driver registration
  • AutoResearch RPC paths continue to function (via the new helper)
  • README + release_notes updated to show `fl::Bus` form first

Activity

  1. added
    type: feature
    area: core
    on May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coretype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions