Skip to content

feat(channels): one-shot affinity-miss diagnostic + normalized driver names (closes #2455) - #2456

Merged
zackees merged 1 commit into
masterfrom
feat/channels-driver-miss-diagnostic-2455
May 11, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/channels-driver-miss-diagnostic-2455

Conversation

@zackees

@zackees zackees commented May 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #2455. Follow-up to #2454 — when a runtime-selected driver isn't registered, give the user an actionable diagnostic instead of silently falling through to priority dispatch.

```cpp
// User forgets to enroll RMT:
FastLED.add(fl::Bus::RMT, cfg);

// On the first show(), one-shot:
// [ERROR] Channel 'Channel_3': Driver 'RMT' wasn't instantiated --
// call fl::enableDriversfl::Bus::RMT() (or fl::enableAllDrivers())
// before adding the channel. Defaulting to AUTO/priority dispatch.

// LEDs still light up via priority fallback. Subsequent shows are silent.
```

What changed

Diagnostic

  • New `bool mAffinityWarned` field on `fl::Channel` — one-shot per channel. The flag flips on the first `showPixels()` that observes an affinity miss; subsequent shows on the same channel skip the log even though the priority-dispatch fallback re-runs each frame.
  • New `fl::isKnownBusName(const fl::string&)` predicate in `fl/channels/bus.h`. When the missing affinity matches a canonical Bus name, the FL_ERROR includes the actionable `fl::enableDriversfl::Bus::X()` hint. For unknown / third-party names, a generic "no registered driver" message fires.
  • Per-frame `ChannelManager::selectDriverForChannel` affinity-miss FL_ERROR is gone — the channel layer now carries the actionable message. `canHandle()` mismatches are demoted to `FL_WARN_ONCE` for similar reasons.

Normalization

Per user request — get rid of the busName/getName divergence entirely. The C++ enumerator spelling is now the single source of truth:

Bus enum Old `getName()` New `getName()`
`Bus::FLEX_IO` `"FLEXIO"` `"FLEX_IO"`
`Bus::OBJECT_FLED` `"OBJECTFLED"` `"OBJECT_FLED"`
`Bus::BIT_BANG` `"BITBANG"` `"BIT_BANG"`
  • `busName(Bus)`, the three driver `getName()` returns, and the matching log-category names in `async_logger.h` all use the same spelling.
  • The pre-PR `busEnumSpelling()` helper (which translated the no-underscore trio for code-suggestion hints) is deleted — `isKnownBusName()` is a flat string compare and the FL_ERROR embeds `mAffinity` verbatim.

No back-compat path because all of this code shipped within the past few PRs (#2451 / #2454 / #2448) — there is no caller in the wild relying on the old spellings.

Tests

Two new host-side cases in `tests/fl/channels/channel.cpp`:

  1. Known Bus miss: affinity="RMT" without enrolling RMT. Asserts the channel renders via priority fallback (host has STUB+BIT_BANG); two consecutive shows leave the bound driver unchanged (verifies the one-shot guard doesn't break dispatch).
  2. Unknown affinity miss: affinity="WAT" — exercises the generic-message branch and verifies the channel still renders.

Plus name updates in the three driver tests + `all_drivers.cpp` for the spelling normalization.

Test plan

  • `bash test channel --cpp` — 1/1 pass.
  • `bash test --cpp` — 303/303 pass (full host suite).
  • `bash lint --cpp` — clean.
  • CI matrix to validate hardware platform builds.

Files changed (13)

Implementation:

  • `src/fl/channels/bus.h` — normalized `busName()` table; new `isKnownBusName()`; removed `busEnumSpelling()`.
  • `src/fl/channels/channel.h` — new `mAffinityWarned` member.
  • `src/fl/channels/channel.cpp.hpp` — the one-shot diagnostic in `showPixels()`.
  • `src/fl/channels/manager.cpp.hpp` — silenced per-frame affinity-miss FL_ERROR; demoted canHandle-miss to FL_WARN_ONCE.
  • `src/fl/log/async_logger.h` — FLEX_IO + OBJECT_FLED log-category renames.
  • `src/platforms/shared/bitbang/bitbang_channel_driver.cpp.hpp` — `"BIT_BANG"`.
  • `src/platforms/arm/teensy/teensy4_common/drivers/flexio/channel_engine_flexio.h` — `"FLEX_IO"`.
  • `src/platforms/arm/teensy/teensy4_common/drivers/objectfled/channel_engine_objectfled.h` — `"OBJECT_FLED"`.

Tests:

  • `tests/fl/channels/all_drivers.cpp` — updated to BIT_BANG.
  • `tests/fl/channels/channel.cpp` — new diagnostic cases + BIT_BANG rename.
  • `tests/platforms/shared/bitbang/bitbang_channel_driver.cpp` — BIT_BANG.
  • `tests/platforms/arm/teensy/teensy4_common/drivers/flexio/channel_engine_flexio.cpp` — FLEX_IO.
  • `tests/platforms/arm/teensy/teensy4_common/drivers/objectfled/channel_engine_objectfled.cpp` — OBJECT_FLED.

Related

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • One-time diagnostic when a configured driver affinity is missing, suppressing repeat warnings.
  • Bug Fixes

    • Standardized bus identifier spellings (FLEX_IO, OBJECT_FLED, BIT_BANG) across the system.
    • Affinity handling now falls back to priority-based driver selection instead of failing immediately.
  • Tests

    • Updated tests to expect the normalized bus identifier spellings and to cover affinity-miss diagnostics.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 11, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fbb291cd-d992-4b70-9ef7-e1982ac0f582

📥 Commits

Reviewing files that changed from the base of the PR and between 724f79f and a48c3ec.

📒 Files selected for processing (14)
  • src/fl/channels/bus.h
  • src/fl/channels/channel.cpp.hpp
  • src/fl/channels/channel.h
  • src/fl/channels/manager.cpp.hpp
  • src/fl/channels/manager.h
  • src/fl/log/async_logger.h
  • src/platforms/arm/teensy/teensy4_common/drivers/flexio/channel_engine_flexio.h
  • src/platforms/arm/teensy/teensy4_common/drivers/objectfled/channel_engine_objectfled.h
  • src/platforms/shared/bitbang/bitbang_channel_driver.cpp.hpp
  • tests/fl/channels/all_drivers.cpp
  • tests/fl/channels/channel.cpp
  • tests/platforms/arm/teensy/teensy4_common/drivers/flexio/channel_engine_flexio.cpp
  • tests/platforms/arm/teensy/teensy4_common/drivers/objectfled/channel_engine_objectfled.cpp
  • tests/platforms/shared/bitbang/bitbang_channel_driver.cpp
✅ Files skipped from review due to trivial changes (5)
  • tests/fl/channels/all_drivers.cpp
  • tests/platforms/arm/teensy/teensy4_common/drivers/objectfled/channel_engine_objectfled.cpp
  • src/fl/log/async_logger.h
  • src/platforms/arm/teensy/teensy4_common/drivers/objectfled/channel_engine_objectfled.h
  • src/platforms/arm/teensy/teensy4_common/drivers/flexio/channel_engine_flexio.h
🚧 Files skipped from review as they are similar to previous changes (8)
  • tests/platforms/arm/teensy/teensy4_common/drivers/flexio/channel_engine_flexio.cpp
  • src/platforms/shared/bitbang/bitbang_channel_driver.cpp.hpp
  • tests/platforms/shared/bitbang/bitbang_channel_driver.cpp
  • src/fl/channels/bus.h
  • src/fl/channels/manager.cpp.hpp
  • src/fl/channels/channel.h
  • src/fl/channels/channel.cpp.hpp
  • tests/fl/channels/channel.cpp

📝 Walkthrough

Walkthrough

This PR normalizes driver name strings to match C++ enumerator spellings (FLEX_IO, OBJECT_FLED, BIT_BANG), adds isKnownBusName(), introduces a silent ChannelManager lookup, implements one-shot per-channel affinity-miss diagnostics with graceful fallback, and updates drivers and tests to the new names.

Changes

Bus Name Normalization & Affinity-Miss Diagnostics

Layer / File(s) Summary
Bus Name String Contract
src/fl/channels/bus.h
busName() now returns underscore-inclusive enumerator spellings and isKnownBusName() validates known concrete bus names; adds fl/stl/string.h.
Driver getName() Implementations
src/platforms/arm/teensy/.../flexio/channel_engine_flexio.h, src/platforms/arm/teensy/.../objectfled/channel_engine_objectfled.h, src/platforms/shared/bitbang/bitbang_channel_driver.cpp.hpp
Engine/driver getName() now return canonical bus names ("FLEX_IO", "OBJECT_FLED", "BIT_BANG").
Logger Category Name Updates
src/fl/log/async_logger.h
Logger category-name literals updated to the canonical bus spellings for disabled-logger diagnostics.
Channel Affinity-Warned Guard
src/fl/channels/channel.h
Adds bool mAffinityWarned to suppress repeated affinity-miss diagnostics per channel.
ChannelManager Silent Lookup & Refactor
src/fl/channels/manager.cpp.hpp, src/fl/channels/manager.h
Adds findDriverByName() silent lookup, refactors getDriverByName() to use it, and documents getDriverByName() logging-on-miss behavior.
Affinity Fallback in Selection
src/fl/channels/manager.cpp.hpp
selectDriverForChannel() no longer hard-fails on missing affinity drivers; it falls back to priority selection and emits one-time warn-once if an affinity driver exists but cannot handle the data.
Channel Affinity-Miss Logging
src/fl/channels/channel.cpp.hpp
showPixels() emits a one-shot FL_ERROR when configured mAffinity doesn't match the runtime-selected driver; message distinguishes known-but-unregistered buses from unknown names and suggests enabling drivers.
Tests / Assertions
tests/fl/channels/*.cpp, tests/platforms/**/drivers/**/*.cpp
Tests updated to expect canonical driver names; new tests added for affinity-miss behavior and host-dispatch assertions adjusted.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2454: Related — both modify/consume canonical bus-name strings and runtime dispatch.
  • FastLED/FastLED#2429: Related — introduces fl::Bus/BusTraits that align with these name changes.
  • FastLED/FastLED#2448: Related — driver registration/lookups that rely on canonical name keys are affected.

Poem

🐰 I hop and fix the names with care,
FLEX_IO and BIT_BANG now wear their share.
One soft warn, then fallbacks hum,
Pixels march on — the show goes on! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: one-shot affinity-miss diagnostic and normalized driver names aligning with Bus enum spelling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/channels-driver-miss-diagnostic-2455

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/fl/channels/channel.cpp.hpp`:
- Around line 334-346: The fallback log incorrectly treats any affinity mismatch
(driver->getName() != mAffinity) as "not instantiated"; update the conditional
and messages to distinguish "no registered/enabled driver" from "registered
driver incompatible." Specifically, instead of using (driver->getName() !=
mAffinity) alone, query the channel/driver registry (e.g.,
ChannelManager::hasDriver or equivalent) to detect whether mAffinity is actually
registered/enabled; if the affinity is not registered, emit the existing "wasn't
instantiated — call fl::enableDrivers<fl::Bus::...>()" message; otherwise, if a
driver for mAffinity exists but is incompatible (driver exists but reports it
cannot handle the channel, e.g., via driver->canHandle(...) or
driver->getName()==mAffinity && !driver->canHandle(...)), emit a
mismatch/incompatibility warning and default to AUTO/priority dispatch. Ensure
the checks reference mDriverPreBound, mAffinity, mAffinityWarned, driver and
isKnownBusName so the correct branch is chosen.

In `@src/fl/channels/manager.cpp.hpp`:
- Around line 291-305: The affinity-miss path is still noisy because
getDriverByName(affinity) emits diagnostics; change the manager to use a
non-diagnostic lookup here by calling a new/overloaded silent lookup (e.g.,
getDriverByNameSilent or getDriverByName(affinity, /*suppressDiagnostics*/
true)) instead of getDriverByName so misses return nullptr without emitting
FL_ERROR, and implement the silent variant to perform the same lookup but not
emit any logs; update the call in the do-block that currently references
getDriverByName(affinity) to use this silent API.

In `@tests/fl/channels/all_drivers.cpp`:
- Around line 51-52: The comment next to the call to mgr.getDriverByName using
the string literal "BIT_BANG" is incorrect; update the comment to match the
literal by removing "(no underscore)" or changing it to "(with underscore)" so
it accurately describes "BIT_BANG" used in the call to
mgr.getDriverByName(fl::string::from_literal("BIT_BANG")).

In `@tests/fl/channels/channel.cpp`:
- Around line 538-566: The test currently triggers an extra FL_ERROR by calling
mgr.getDriverByName("RMT") and never asserts the one-shot affinity diagnostic;
change the test to avoid provoking that extra error and explicitly capture logs
around the two showLeds() calls and assert exactly one affinity-miss FL_ERROR
was emitted. Concretely: remove or replace the call to getDriverByName("RMT")
(which causes an unwanted error) and wrap the first and second
channel->showLeds(0) calls with the test log-capture utility (e.g., captureLogs
or the project test logger), then assert the captured logs contain one and only
one FL_ERROR message mentioning the affinity miss for the channel (and assert
driver binding stability as before using channel->getEngineName()).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cec8abc2-535d-4593-8f6d-4bf5dfed3363

📥 Commits

Reviewing files that changed from the base of the PR and between 55182fe and 724f79f.

📒 Files selected for processing (13)
  • src/fl/channels/bus.h
  • src/fl/channels/channel.cpp.hpp
  • src/fl/channels/channel.h
  • src/fl/channels/manager.cpp.hpp
  • src/fl/log/async_logger.h
  • src/platforms/arm/teensy/teensy4_common/drivers/flexio/channel_engine_flexio.h
  • src/platforms/arm/teensy/teensy4_common/drivers/objectfled/channel_engine_objectfled.h
  • src/platforms/shared/bitbang/bitbang_channel_driver.cpp.hpp
  • tests/fl/channels/all_drivers.cpp
  • tests/fl/channels/channel.cpp
  • tests/platforms/arm/teensy/teensy4_common/drivers/flexio/channel_engine_flexio.cpp
  • tests/platforms/arm/teensy/teensy4_common/drivers/objectfled/channel_engine_objectfled.cpp
  • tests/platforms/shared/bitbang/bitbang_channel_driver.cpp

Comment thread src/fl/channels/channel.cpp.hpp Outdated
Comment on lines +334 to +346
if (!mDriverPreBound && !mAffinity.empty() && !mAffinityWarned) {
const bool affinityMiss = !driver ||
(driver->getName() != mAffinity);
if (affinityMiss) {
if (isKnownBusName(mAffinity)) {
FL_ERROR("Channel '" << mName << "': Driver '" << mAffinity
<< "' wasn't instantiated — call fl::enableDrivers<fl::Bus::"
<< mAffinity
<< ">() (or fl::enableAllDrivers()) before adding the channel. "
<< "Defaulting to AUTO/priority dispatch.");
} else {
FL_ERROR("Channel '" << mName << "': Affinity '" << mAffinity
<< "' has no registered driver. Defaulting to AUTO/priority dispatch.");

@coderabbitai coderabbitai Bot May 11, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Affinity diagnostic currently mislabels incompatibility as “not instantiated.”

Lines 335-346 treat any fallback (driver->getName() != mAffinity) as a registration miss. That also catches the “affinity driver exists but canHandle() failed” path, so the enableDrivers<fl::Bus::...>() guidance is incorrect in that case.

Please gate this message on an explicit “not found/not enabled” reason from ChannelManager (or equivalent), and keep incompatibility on the mismatch warning path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fl/channels/channel.cpp.hpp` around lines 334 - 346, The fallback log
incorrectly treats any affinity mismatch (driver->getName() != mAffinity) as
"not instantiated"; update the conditional and messages to distinguish "no
registered/enabled driver" from "registered driver incompatible." Specifically,
instead of using (driver->getName() != mAffinity) alone, query the
channel/driver registry (e.g., ChannelManager::hasDriver or equivalent) to
detect whether mAffinity is actually registered/enabled; if the affinity is not
registered, emit the existing "wasn't instantiated — call
fl::enableDrivers<fl::Bus::...>()" message; otherwise, if a driver for mAffinity
exists but is incompatible (driver exists but reports it cannot handle the
channel, e.g., via driver->canHandle(...) or driver->getName()==mAffinity &&
!driver->canHandle(...)), emit a mismatch/incompatibility warning and default to
AUTO/priority dispatch. Ensure the checks reference mDriverPreBound, mAffinity,
mAffinityWarned, driver and isKnownBusName so the correct branch is chosen.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a48c3ec. The channel-side diagnostic now probes the registry directly via the new silent ChannelManager::findDriverByName(mAffinity). Branches: registry returns null → "wasn't instantiated, call enableDriversBus::X()"; registry returns a driver (so the priority fallback fired because canHandle() rejected this chipset) → "registered but cannot handle this channel's chipset (bus/chipset mismatch)". Resolution paths are now distinct.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zackees, confirmed — the updated logic in the file_content correctly implements both branches:

  • findDriverByName returns null → driver was never instantiated → emits the enableDrivers<fl::Bus::X>() / enableAllDrivers() hint (gated on isKnownBusName).
  • findDriverByName returns a driver → it exists but canHandle() rejected the chipset → emits the "registered but cannot handle this channel's chipset (bus/chipset mismatch)" message.

The mAffinityWarned = true guard is still set after either branch, so the one-shot behavior is preserved. The original concern is fully addressed. ✅


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

Comment thread src/fl/channels/manager.cpp.hpp Resolved
Comment thread tests/fl/channels/all_drivers.cpp Resolved
Comment on lines +538 to +566
FL_TEST_CASE("Affinity miss to unregistered known Bus falls back and still renders") {
auto& mgr = freshBusTestManager();
FL_REQUIRE(mgr.getDriverCount() == 0);

// Register ONLY the host fallbacks (STUB + BIT_BANG via enableAllDrivers).
// We do not register Bus::RMT, so an affinity = "RMT" must miss.
fl::enableAllDrivers();
FL_CHECK(mgr.getDriverByName(fl::string::from_literal("RMT")) == nullptr);

CRGB leds[8] = {};
ChannelConfig cfg = makeBusTestConfig(fl::span<CRGB>(leds, 8));
// Forge a runtime affinity for a Bus whose driver is NOT registered.
cfg.options.mAffinity = fl::string::from_literal("RMT");

auto channel = Channel::create(cfg);
FL_REQUIRE(channel != nullptr);
channel->addToDrawList();

// First show: the diagnostic fires AND priority dispatch picks a host
// driver (STUB or BIT_BANG). Channel still renders.
channel->showLeds(0);
auto bound = channel->getEngineName();
FL_CHECK(bound == fl::string::from_literal("STUB") ||
bound == fl::string::from_literal("BIT_BANG"));

// Second show: mAffinityWarned suppresses the duplicate diagnostic.
// Driver binding is unchanged.
channel->showLeds(0);
FL_CHECK(channel->getEngineName() == bound);

@coderabbitai coderabbitai Bot May 11, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

One-shot diagnostic behavior isn’t actually asserted in this test.

Lines 563-566 only check driver stability; they don’t verify that the affinity-miss FL_ERROR occurs exactly once. Also, Line 545 currently triggers an extra FL_ERROR via getDriverByName("RMT"), which can interfere with a future log-count assertion.

Please capture logs around the two showLeds() calls and assert exactly one affinity-miss error for this channel.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/fl/channels/channel.cpp` around lines 538 - 566, The test currently
triggers an extra FL_ERROR by calling mgr.getDriverByName("RMT") and never
asserts the one-shot affinity diagnostic; change the test to avoid provoking
that extra error and explicitly capture logs around the two showLeds() calls and
assert exactly one affinity-miss FL_ERROR was emitted. Concretely: remove or
replace the call to getDriverByName("RMT") (which causes an unwanted error) and
wrap the first and second channel->showLeds(0) calls with the test log-capture
utility (e.g., captureLogs or the project test logger), then assert the captured
logs contain one and only one FL_ERROR message mentioning the affinity miss for
the channel (and assert driver binding stability as before using
channel->getEngineName()).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed in a48c3ec. Removed the getDriverByName("RMT") call that was emitting its own FL_ERROR (now uses the new silent findDriverByName). Did NOT add the log-count assertion — the project log macros have no capture/intercept hook today, so a count assertion isn't feasible without new test infrastructure. Added a comment in the test explaining the behavioural proxy (dispatch falls back to a host driver; bound driver stable across shows; mAffinityWarned latches unconditionally). If a follow-up adds an FL_LOG_CAPTURE utility, this test can be tightened.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zackees, thanks for the update. The two parts break down cleanly:

  • getDriverByName → findDriverByName — fully resolved. The silent lookup eliminates the spurious FL_ERROR that would have polluted any future log-count assertion.
  • Log-count assertion — the deferral is reasonable. Without a capture/intercept hook on FL_ERROR, a count assertion would either require invasive changes to the logging layer or a test-only global side-channel, neither of which belongs in this PR. The behavioral proxy (stable bound-driver across two showLeds() calls + the unconditional mAffinityWarned latch documented in the comment) is a sound substitute for now.

Would you like me to open a follow-up GitHub issue to track adding an FL_LOG_CAPTURE / log-intercept test utility so this test can be tightened later?

… names (closes #2455)

When a runtime affinity is set but the named driver isn't registered with
ChannelManager (e.g., the user wrote FastLED.add(fl::Bus::RMT, cfg) without
calling enableAllDrivers() / enableDrivers<Bus::RMT>() first), Channel::
showPixels now emits exactly one FL_ERROR on the first show() of that
channel:

  Channel 'Channel_3': Driver 'RMT' wasn't instantiated --
  call fl::enableDrivers<fl::Bus::RMT>() (or fl::enableAllDrivers()) before
  adding the channel. Defaulting to AUTO/priority dispatch.

The new mAffinityWarned per-channel flag suppresses duplicates on every
subsequent show. Dispatch still falls through to ChannelManager's priority
search so LEDs still light up.

For unknown / third-party affinity strings (not one of fl::Bus's canonical
names) the message drops the fl::Bus::X hint and just reports the missing
driver. The per-frame ERROR-level log in ChannelManager::selectDriverForChannel
is now silent in the affinity-miss path -- the Channel layer carries the
actionable message. canHandle() mismatches are demoted to FL_WARN_ONCE.

Also normalized three driver getName() returns + their log categories to
match the C++ enumerator spelling (with underscores) -- no more divergence:

  Bus::FLEX_IO     -> "FLEX_IO"     (was "FLEXIO")
  Bus::OBJECT_FLED -> "OBJECT_FLED" (was "OBJECTFLED")
  Bus::BIT_BANG    -> "BIT_BANG"    (was "BITBANG")

The previous busEnumSpelling() helper is gone -- single source of truth in
bus.h's busName() table now matches getName() everywhere, so isKnownBusName()
is a flat string compare and the FL_ERROR message embeds mAffinity verbatim
without translation.

Tests cover:
- Known Bus miss: actionable FL_ERROR + priority fallback + render success.
- Unknown affinity miss: generic FL_ERROR + priority fallback.
- Repeat shows do not re-log (mAffinityWarned guard works).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees force-pushed the feat/channels-driver-miss-diagnostic-2455 branch from 724f79f to a48c3ec Compare May 11, 2026 19:02
@zackees
zackees merged commit b089be8 into master May 11, 2026
21 of 22 checks passed
zackees added a commit that referenced this pull request May 11, 2026
…bleAllDrivers + diagnostics) (#2458)

The channels README hadn't been updated since #2435 (Phase 3a) while the
real API surface grew through #2437/2438/2441/2448/2449/2450/2451/2454/
2456. This refresh aligns the docs with what the code actually does today.

Reviewed in three independent sub-agent passes:

- Pass 1 (broad accuracy): added the new dual-mode dispatch architecture
  section (compile-time `fl::Bus` binding vs runtime `ChannelManager`),
  the templated `Channel::create<Bus B>(cfg)` / `FastLED.add<Bus B>(cfg)`
  examples, the `ChannelConfigOf<Chipset>` + `TypedChannel<Bus, Chipset>`
  Phase 3b API, the `enableDrivers<>()` / `enableAllDrivers()` opt-in
  registry, the `FASTLED_DISABLE_LEGACY_DRIVER_REGISTRY` binary-size
  macro, the one-shot affinity-miss diagnostic (#2456), and the
  driver-name rename callout (BITBANG -> BIT_BANG, FLEXIO -> FLEX_IO,
  OBJECTFLED -> OBJECT_FLED). Updated the registration example to the
  current 2-arg `addDriver(priority, driver)` signature; the name comes
  from `driver->getName()`. Expanded the Reference section to list the
  new headers (`bus.h`, `bus_traits.h`, `all_drivers.h`, `channel_typed.h`,
  `ichannel.h`) and to include `findDriverByName` / `clearAllDrivers` on
  `manager.h`.

- Pass 2 (independent verification): fixed two real bugs the first pass
  left in place. (a) DMA wait-pattern snippet referenced a nonexistent
  `EngineState::READY` — corrected to `IChannelDriver::DriverState::READY`.
  (b) "Overriding Engine Selection" examples called a nonexistent
  `FastLED.setDriverPriority(...)` — the method lives only on
  `ChannelManager::setDriverPriority`; rewrote both call sites to
  `fl::ChannelManager::instance().setDriverPriority(...)` with an
  explanatory comment about the API asymmetry vs the
  `setDriverEnabled` / `setExclusiveDriver` helpers that DO have
  CFastLED forwarders.

- Pass 3 (polish): added missing file-scope `CRGB leds[60];` declarations
  to two example snippets that referenced `leds` without anchoring it.
  Inserted an "alternatives, not a sequence" clarifier above the three
  Override Methods so a careful reader doesn't think calling all three in
  order is intended. Verified the `Bus::AUTO` story end-to-end:
  `FastLED.add<fl::Bus::AUTO>(cfg)` never appears as an example (the
  static_assert from #2451 rejects it); only `FastLED.add(cfg)` (implicit
  default via `ChannelConfigOf`) and `FastLED.add(fl::Bus::AUTO, cfg)`
  (runtime form, clears affinity) are shown.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the feat/channels-driver-miss-diagnostic-2455 branch May 30, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Channel API: FL_ERROR + AUTO-fallback when a runtime-selected driver wasn't instantiated

1 participant