Skip to content

Feat/channels bus traits drivers - #2435

Merged
zackees merged 1 commit into
masterfrom
feat/channels-bus-traits-drivers
May 10, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/channels-bus-traits-drivers

Conversation

@zackees

@zackees zackees commented May 10, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added a generic channel interface so listeners can handle different channel implementations.
  • Refactor

    • Updated channel event callbacks to use the generic interface type for broader compatibility.
  • Documentation

    • Updated examples and README snippets to show the new callback parameter types and minor log formatting.
  • Tests

    • Adjusted tests to use the interface-based callbacks.
  • Bug Fixes

    • Improved handling of keyboard interrupts during lock release/cleanup.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 10, 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: 1aa080c3-5fc9-45ff-907e-1e059d453157

📥 Commits

Reviewing files that changed from the base of the PR and between a84ac1b and b0f49c8.

📒 Files selected for processing (9)
  • src/FastLED.h
  • src/fl/channels/README.md
  • src/fl/channels/channel.h
  • src/fl/channels/channel_events.h
  • src/fl/channels/ichannel.h
  • test.py
  • tests/fastled_core.cpp
  • tests/fl/channels/driver.cpp
  • tests/fl/chipsets/ucs7604.cpp
✅ Files skipped from review due to trivial changes (2)
  • src/fl/channels/README.md
  • src/FastLED.h
🚧 Files skipped from review as they are similar to previous changes (7)
  • tests/fl/channels/driver.cpp
  • tests/fl/chipsets/ucs7604.cpp
  • src/fl/channels/channel.h
  • src/fl/channels/ichannel.h
  • tests/fastled_core.cpp
  • test.py
  • src/fl/channels/channel_events.h

📝 Walkthrough

Walkthrough

This PR introduces the IChannel polymorphic interface, makes Channel implement it (id()/name() overrides), updates ChannelEvents to accept const IChannel& for channel parameters, updates docs/examples to match, updates tests to use IChannel, and adds explicit KeyboardInterrupt handling in test utilities.

Changes

IChannel Interface and ChannelEvents Integration

Layer / File(s) Summary
IChannel Interface Definition
src/fl/channels/ichannel.h
New non-copyable, non-movable base class providing virtual id() and name() accessors and protected default constructor.
Channel Interface Integration
src/fl/channels/channel.h
Channel includes ichannel.h, inherits from IChannel, and marks id() and name() as override.
ChannelEvents Callback Abstraction
src/fl/channels/channel_events.h
All event listener types updated to accept const IChannel& instead of const Channel& for channel parameters; header forwards IChannel.
Public API Documentation
src/FastLED.h, src/fl/channels/README.md
Examples and comments updated to reflect const fl::IChannel& callback signatures and ASCII separator in README example.
Test Updates
tests/fastled_core.cpp, tests/fl/channels/driver.cpp, tests/fl/chipsets/ucs7604.cpp
EventTracker and test listener lambdas updated to accept const fl::IChannel&; assertions and other parameters unchanged.

Test Runner KeyboardInterrupt Handling

Layer / File(s) Summary
KeyboardInterrupt Preservation
test.py
_release_held_build_locks() and deadman timer exception handling now explicitly catch and suppress KeyboardInterrupt via handle_keyboard_interrupt(), allowing cleanup to complete before exit.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2251 — related changes to Channel constructors and driver bindings that overlap with Channel API edits.

Poem

🐰 I hopped through headers, light and keen,
IChannel now sits where templates have been,
Listeners gather, agnostic and spry,
Tests nod and the watchdog keeps watch by,
A rabbit-approved refactor — hop, hi!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.13% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and generic, using non-descriptive terms ('Feat/channels' and 'bus traits drivers') that don't clearly convey the main change. The changeset introduces an IChannel interface abstraction to decouple event callbacks from concrete Channel types, but the title doesn't reflect this primary objective. Replace with a specific title that captures the main change, such as 'Add IChannel interface abstraction for channel event decoupling' or 'Introduce IChannel polymorphic base class for channel callbacks'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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-bus-traits-drivers

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: 2

♻️ Duplicate comments (4)
src/platforms/esp/32/drivers/rmt/rmt_4/bus_traits.h (1)

1-1: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use compiler control macros instead of raw #pragma once.

Replace the raw #pragma once directive with the appropriate FastLED compiler control macro.

As per coding guidelines: "Use FastLED compiler control macros from fl/stl/compiler_control.h instead of raw #pragma directives".

🤖 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/platforms/esp/32/drivers/rmt/rmt_4/bus_traits.h` at line 1, Replace the
raw `#pragma once` in bus_traits.h with the FastLED compiler control macros:
include "fl/stl/compiler_control.h" and wrap the header with the begin/end
compiler-control macros provided by that header (remove the `#pragma once` and
use the FastLED macros instead to ensure consistent compiler directive
handling).
src/platforms/esp/32/drivers/i2s_spi/bus_traits.h (1)

1-1: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use compiler control macros instead of raw #pragma once.

Same as in src/platforms/arm/teensy/teensy4_common/drivers/flexio/bus_traits.h: replace the raw #pragma once directive with the appropriate FastLED compiler control macro.

As per coding guidelines: "Use FastLED compiler control macros from fl/stl/compiler_control.h instead of raw #pragma directives".

🤖 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/platforms/esp/32/drivers/i2s_spi/bus_traits.h` at line 1, Replace the raw
"#pragma once" in src/platforms/esp/32/drivers/i2s_spi/bus_traits.h with the
FastLED compiler control macros: add `#include` <fl/stl/compiler_control.h> at the
top and wrap the header with the project's header guard macros (e.g.,
FASTLED_BEGIN_HEADER / FASTLED_END_HEADER or the equivalent macros provided by
fl/stl/compiler_control.h) so the file uses the FastLED compiler control macros
instead of a raw pragma.
src/platforms/esp/32/drivers/rmt/rmt_5/bus_traits.h (1)

1-1: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use compiler control macros instead of raw #pragma once.

Replace the raw #pragma once directive with the appropriate FastLED compiler control macro.

As per coding guidelines: "Use FastLED compiler control macros from fl/stl/compiler_control.h instead of raw #pragma directives".

🤖 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/platforms/esp/32/drivers/rmt/rmt_5/bus_traits.h` at line 1, Replace the
raw "#pragma once" in src/platforms/esp/32/drivers/rmt/rmt_5/bus_traits.h with
the FastLED compiler control macros: remove the pragma, add `#include`
"fl/stl/compiler_control.h", and wrap the header with the provided header-guard
macros from that file (use the library's header-enter and header-exit macros,
e.g., FL_COMPILER_CONTROL_HEADER / FL_COMPILER_CONTROL_FOOTER or the equivalent
names defined in fl/stl/compiler_control.h) so the file uses the FastLED
compiler control macros instead of a raw pragma.
src/fl/channels/ichannel.h (1)

1-1: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use compiler control macros instead of raw #pragma once.

Replace the raw #pragma once directive with the appropriate FastLED compiler control macro from fl/stl/compiler_control.h.

As per coding guidelines: "Use FastLED compiler control macros from fl/stl/compiler_control.h instead of raw #pragma directives".

🤖 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/ichannel.h` at line 1, Replace the raw `#pragma once` in
src/fl/channels/ichannel.h: remove the `#pragma once` line, add `#include
"fl/stl/compiler_control.h"` and wrap this header's declarations with the
FastLED compiler control macros provided by that header (use the begin/end or
push/pop macros defined there) so the file uses the library's compiler control
instead of the raw pragma.
🤖 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/platforms/esp/32/drivers/uart/bus_traits.h`:
- Around line 32-42: The instance() singleton constructs Holder using
fl::make_shared (via UartPeripheralEsp and Driver) which assumes allocations
never return nullptr; under -fno-exceptions fl::aligned_alloc (and
fl::make_shared) can return null and will be dereferenced causing a crash. Fix
by changing Holder to hold fl::optional<fl::shared_ptr<UartPeripheralEsp>> and
fl::optional<fl::shared_ptr<Driver>> (or at least make driver optional), check
the optionals after attempting fl::make_shared in Holder's constructor and
handle allocation failure by returning a safe error path from instance() (e.g.,
return a null/optional result or call a controlled abort/assertion);
alternatively, if you prefer the other approach, make fl::aligned_alloc
explicitly abort/assert on allocation failure so the current no-check pattern is
explicit—apply the selected fix to the instance(), Holder, and analogous
singleton patterns that use fl::make_shared.

In `@test.py`:
- Around line 195-197: The except block currently catches KeyboardInterrupt,
calls handle_keyboard_interrupt(ki), then re-raises, which allows watchdog
threads (deadman_timer and watchdog_timer) to exit before they can call
os._exit(); instead, suppress KeyboardInterrupt in this best-effort cleanup path
by removing the re-raise so the cleanup returns normally after
handle_keyboard_interrupt(ki). Apply the same change to the other occurrence
referenced (the second except block around lines ~200-202) so both best-effort
cleanup sites called by deadman_timer() and watchdog_timer() do not propagate
KeyboardInterrupt.

---

Duplicate comments:
In `@src/fl/channels/ichannel.h`:
- Line 1: Replace the raw `#pragma once` in src/fl/channels/ichannel.h: remove
the `#pragma once` line, add `#include "fl/stl/compiler_control.h"` and wrap
this header's declarations with the FastLED compiler control macros provided by
that header (use the begin/end or push/pop macros defined there) so the file
uses the library's compiler control instead of the raw pragma.

In `@src/platforms/esp/32/drivers/i2s_spi/bus_traits.h`:
- Line 1: Replace the raw "#pragma once" in
src/platforms/esp/32/drivers/i2s_spi/bus_traits.h with the FastLED compiler
control macros: add `#include` <fl/stl/compiler_control.h> at the top and wrap the
header with the project's header guard macros (e.g., FASTLED_BEGIN_HEADER /
FASTLED_END_HEADER or the equivalent macros provided by
fl/stl/compiler_control.h) so the file uses the FastLED compiler control macros
instead of a raw pragma.

In `@src/platforms/esp/32/drivers/rmt/rmt_4/bus_traits.h`:
- Line 1: Replace the raw `#pragma once` in bus_traits.h with the FastLED
compiler control macros: include "fl/stl/compiler_control.h" and wrap the header
with the begin/end compiler-control macros provided by that header (remove the
`#pragma once` and use the FastLED macros instead to ensure consistent compiler
directive handling).

In `@src/platforms/esp/32/drivers/rmt/rmt_5/bus_traits.h`:
- Line 1: Replace the raw "#pragma once" in
src/platforms/esp/32/drivers/rmt/rmt_5/bus_traits.h with the FastLED compiler
control macros: remove the pragma, add `#include` "fl/stl/compiler_control.h", and
wrap the header with the provided header-guard macros from that file (use the
library's header-enter and header-exit macros, e.g., FL_COMPILER_CONTROL_HEADER
/ FL_COMPILER_CONTROL_FOOTER or the equivalent names defined in
fl/stl/compiler_control.h) so the file uses the FastLED compiler control macros
instead of a raw pragma.
🪄 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: 6eef103b-0956-4945-9dd5-500f5b766033

📥 Commits

Reviewing files that changed from the base of the PR and between d450c50 and da8e588.

📒 Files selected for processing (34)
  • src/FastLED.h
  • src/fl/channels/README.md
  • src/fl/channels/bus.h
  • src/fl/channels/channel.h
  • src/fl/channels/channel_events.h
  • src/fl/channels/ichannel.h
  • src/platforms/arm/teensy/teensy4_common/drivers/flexio/_build.cpp.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/flexio/bus_traits.h
  • src/platforms/arm/teensy/teensy4_common/drivers/objectfled/_build.cpp.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/objectfled/bus_traits.h
  • src/platforms/esp/32/drivers/i2s/_build.cpp.hpp
  • src/platforms/esp/32/drivers/i2s/bus_traits.h
  • src/platforms/esp/32/drivers/i2s_spi/_build.cpp.hpp
  • src/platforms/esp/32/drivers/i2s_spi/bus_traits.h
  • src/platforms/esp/32/drivers/lcd_cam/_build.cpp.hpp
  • src/platforms/esp/32/drivers/lcd_cam/bus_traits.h
  • src/platforms/esp/32/drivers/lcd_spi/_build.cpp.hpp
  • src/platforms/esp/32/drivers/lcd_spi/bus_traits.h
  • src/platforms/esp/32/drivers/parlio/_build.cpp.hpp
  • src/platforms/esp/32/drivers/parlio/bus_traits.h
  • src/platforms/esp/32/drivers/rmt/rmt_4/_build.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_4/bus_traits.h
  • src/platforms/esp/32/drivers/rmt/rmt_5/_build.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_5/bus_traits.h
  • src/platforms/esp/32/drivers/spi/_build.cpp.hpp
  • src/platforms/esp/32/drivers/spi/bus_traits.h
  • src/platforms/esp/32/drivers/uart/_build.cpp.hpp
  • src/platforms/esp/32/drivers/uart/bus_traits.h
  • src/platforms/shared/bitbang/_build.cpp.hpp
  • src/platforms/shared/bitbang/bus_traits.h
  • test.py
  • tests/fastled_core.cpp
  • tests/fl/channels/driver.cpp
  • tests/fl/chipsets/ucs7604.cpp

Comment on lines +32 to +42
static Driver& instance() FL_NOEXCEPT {
struct Holder {
fl::shared_ptr<UartPeripheralEsp> peripheral;
fl::shared_ptr<Driver> driver;
Holder() FL_NOEXCEPT
: peripheral(fl::make_shared<UartPeripheralEsp>()),
driver(fl::make_shared<Driver>(peripheral)) {}
};
static Holder gHolder;
return *gHolder.driver;
}

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 | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify fl::make_shared allocation failure behavior and similar patterns in codebase.

# Test 1: Find fl::make_shared implementation
echo "=== Finding fl::make_shared implementation ==="
ast-grep --pattern $'namespace fl {
  $$$
  make_shared($$$) {
    $$$
  }
  $$$
}'

# Test 2: Check for similar singleton patterns with make_shared
echo "=== Checking similar static singleton patterns ==="
rg -A 5 'static.*fl::make_shared' --type=cpp -C 3

# Test 3: Check if codebase uses -fno-exceptions
echo "=== Checking for exception handling flags ==="
rg -g 'CMakeLists.txt' -g 'Makefile' -g '*.cmake' -i 'fno-exceptions|exceptions'

# Test 4: Look for null checks after make_shared calls
echo "=== Sample null checks after make_shared ==="
rg -A 2 'fl::make_shared' --type=cpp | rg -B 2 'if.*null|assert'

Repository: FastLED/FastLED

Length of output: 22715


🏁 Script executed:

#!/bin/bash
# Find fl:: namespace definition and make_shared implementation

echo "=== Searching for fl namespace and shared_ptr implementation ==="
fd -e h -e hpp | xargs grep -l "namespace fl" | head -10

echo ""
echo "=== Looking for shared_ptr definition in fl ==="
rg "template.*shared_ptr|class shared_ptr" --type=hpp | head -20

echo ""
echo "=== Checking fl/stl directory for memory/pointer implementations ==="
fd "shared_ptr|make_shared" src/fl/stl --type f

echo ""
echo "=== Searching for fl::make_shared definition ==="
rg "make_shared\s*\(" src/fl/stl --type=hpp -A 3 | head -30

Repository: FastLED/FastLED

Length of output: 713


🏁 Script executed:

#!/bin/bash
# Read the fl::shared_ptr implementation files

echo "=== Reading shared_ptr.h ==="
wc -l src/fl/stl/shared_ptr.h
head -100 src/fl/stl/shared_ptr.h

echo ""
echo "=== Checking for make_shared in shared_ptr.h ==="
grep -n "make_shared" src/fl/stl/shared_ptr.h

echo ""
echo "=== Reading shared_ptr.cpp.hpp ==="
wc -l src/fl/stl/shared_ptr.cpp.hpp
head -100 src/fl/stl/shared_ptr.cpp.hpp

echo ""
echo "=== Searching for make_shared implementation ==="
grep -n "make_shared" src/fl/stl/shared_ptr.cpp.hpp | head -10

Repository: FastLED/FastLED

Length of output: 6686


🏁 Script executed:

#!/bin/bash
# Find the allocate function implementation

echo "=== Searching for allocate function in fl::stl ==="
rg -n "template.*allocate|allocate\s*<" src/fl/stl/shared_ptr.h | head -20

echo ""
echo "=== Looking for allocate in other stl files ==="
fd -type f src/fl/stl | xargs grep -l "allocate" 2>/dev/null

echo ""
echo "=== Searching for allocate definition ==="
rg -n "^.*allocate\s*\(" src/fl/stl --type=hpp -B 2 -A 5 | head -40

Repository: FastLED/FastLED

Length of output: 419


🏁 Script executed:

#!/bin/bash
# Read the make_shared implementation more carefully

echo "=== Reading lines 410-450 of shared_ptr.h where make_shared is defined ==="
sed -n '410,450p' src/fl/stl/shared_ptr.h

echo ""
echo "=== Looking for allocate function in shared_ptr.h ==="
grep -n "allocate" src/fl/stl/shared_ptr.h

echo ""
echo "=== Search for InlinedControlBlock definition ==="
sed -n '100,160p' src/fl/stl/shared_ptr.h

Repository: FastLED/FastLED

Length of output: 4616


🏁 Script executed:

#!/bin/bash
# Find fl::aligned_alloc implementation

echo "=== Searching for aligned_alloc definition ==="
find src/fl/stl -type f -name "*.h" -o -name "*.cpp.hpp" | xargs grep -l "aligned_alloc" 2>/dev/null

echo ""
echo "=== Reading aligned_alloc implementation ==="
grep -n "aligned_alloc" src/fl/stl/*.h -A 5 | head -40

echo ""
echo "=== Checking cstdlib for memory allocation ==="
head -50 src/fl/stl/cstdlib.h

Repository: FastLED/FastLED

Length of output: 3872


🏁 Script executed:

#!/bin/bash
# Find the actual implementation of aligned_alloc

echo "=== Reading cstdlib.cpp.hpp for aligned_alloc implementation ==="
grep -n "aligned_alloc" src/fl/stl/cstdlib.cpp.hpp -A 20 | head -60

echo ""
echo "=== Checking if aligned_alloc can return null or asserts ==="
cat src/fl/stl/cstdlib.cpp.hpp | grep -A 30 "void \*aligned_alloc"

Repository: FastLED/FastLED

Length of output: 3227


🏁 Script executed:

#!/bin/bash
# Verify the critical issue: operator new can return null with -fno-exceptions

echo "=== Checking how standard C++ handles null from operator new with -fno-exceptions ==="
cat src/fl/stl/noexcept.h | head -30

echo ""
echo "=== Double-check: Does make_shared handle null from operator new? ==="
sed -n '414,420p' src/fl/stl/shared_ptr.h

echo ""
echo "=== Verify similar patterns in codebase are also unchecked ==="
grep -n "fl::make_shared" src/platforms/shared/bitbang/bus_traits.h -B 2 -A 3

Repository: FastLED/FastLED

Length of output: 1491


Allocation failure handling is unsafe in no-exceptions environment.

The instance() method calls fl::make_shared without checking for allocation failure. With -fno-exceptions compilation (as enforced by the project), fl::aligned_alloc → malloc can return nullptr on failure. The make_shared implementation does not check for null and immediately dereferences the pointer (lines 416, 418, 419), causing a crash if memory allocation fails.

The same pattern exists throughout the codebase but violates the coding guideline: "use error codes or fl::optional instead" of try-catch blocks or exception handling.

Fix: Either use fl::optional<fl::shared_ptr<Driver>> and handle the null case in instance(), or add an abort/assertion in fl::aligned_alloc on allocation failure to make the no-check pattern explicit and safe.

🤖 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/platforms/esp/32/drivers/uart/bus_traits.h` around lines 32 - 42, The
instance() singleton constructs Holder using fl::make_shared (via
UartPeripheralEsp and Driver) which assumes allocations never return nullptr;
under -fno-exceptions fl::aligned_alloc (and fl::make_shared) can return null
and will be dereferenced causing a crash. Fix by changing Holder to hold
fl::optional<fl::shared_ptr<UartPeripheralEsp>> and
fl::optional<fl::shared_ptr<Driver>> (or at least make driver optional), check
the optionals after attempting fl::make_shared in Holder's constructor and
handle allocation failure by returning a safe error path from instance() (e.g.,
return a null/optional result or call a controlled abort/assertion);
alternatively, if you prefer the other approach, make fl::aligned_alloc
explicitly abort/assert on allocation failure so the current no-check pattern is
explicit—apply the selected fix to the instance(), Holder, and analogous
singleton patterns that use fl::make_shared.

Comment thread test.py Resolved
zackees added a commit that referenced this pull request May 10, 2026
…3a of #2428)

Adds a non-template polymorphic anchor `fl::IChannel` so ChannelEvents callbacks
keep working after `Channel<Bus, Chipset>` becomes a template in Phase 3b.
Pure API surface refactor -- no behavior changes.

- New: src/fl/channels/ichannel.h. Minimal ABC with virtual `id()` and `name()`,
  noexcept special members, non-copyable/movable. Holds the public surface that
  any callback might reasonably want.
- Channel now derives from CPixelLEDController<RGB> AND IChannel; existing
  `id()` / `name()` accessors marked `override`.
- ChannelEvents callbacks change from `function_list<void(const Channel&, ...)>`
  to `function_list<void(const IChannel&, ...)>`. Callsites that fire events
  pass `*this` which upcasts implicitly via the new inheritance.
- Test/doc lambdas migrated: tests/fastled_core.cpp EventTracker stores
  `const IChannel*`; lambdas in fastled_core.cpp, fl/channels/driver.cpp,
  fl/chipsets/ucs7604.cpp updated. README and FastLED.h docstrings refreshed.

Also fixes pre-existing KBI checker failures in test.py (lines 186/193/211)
flagged by lint -- the test-lock fix from #2432 introduced try-except blocks
catching Exception without KeyboardInterrupt re-raise. Added the standard
`except KeyboardInterrupt as ki: handle_keyboard_interrupt(ki)` clause before
each `except Exception`. Per CodeRabbit feedback on PR #2435, the cleanup
intentionally suppresses (does NOT re-raise) KeyboardInterrupt because:
- _release_held_build_locks() is best-effort cleanup called by deadman_timer
  and watchdog_timer, both of which call os._exit() unconditionally afterward.
- Re-raising would short-circuit the os._exit() and defeat the watchdog.

Verification:
- bash lint clean.
- bash test --cpp passes (303/303).
- ChannelEvents tests verified: pointer-identity comparisons
  `tracker.mLastChannel == channel.get()` still work because Channel inherits
  from IChannel (implicit upcast).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees force-pushed the feat/channels-bus-traits-drivers branch from da8e588 to a84ac1b Compare May 10, 2026 01:37
@zackees

zackees commented May 10, 2026

Copy link
Copy Markdown
Member Author

Squashed and addressed CodeRabbit feedback

Force-pushed a single squashed commit replacing the prior 2-commit history.

Addressed

test.py — KeyboardInterrupt handling in watchdog cleanup (Major / Poor tradeoff)
You're right that re-raising KeyboardInterrupt inside _release_held_build_locks() defeats the watchdog's os._exit(). Removed the raise from both call sites:

  • _release_held_build_locks() itself (both inner and outer except KeyboardInterrupt).
  • deadman_timer()'s call-site wrapper.

The function now satisfies the KBI001 lint rule (handle_keyboard_interrupt(ki) called) but no longer propagates, so the unconditional os._exit(3) afterward always runs. Added explanatory comments at both sites.

Skipped with rationale

uart/bus_traits.h — fl::make_shared allocation failure (Critical)
This is a project-wide pattern, not new in this PR. The same fl::make_shared<UartPeripheralEsp>() + fl::make_shared<ChannelEngineUART>(peripheral) sequence (no null check) already exists in src/platforms/esp/32/drivers/channel_manager_esp32.cpp.hpp:233-235 (the file my BusTraits is mirroring). Every other driver factory in the codebase has the same shape.

Fixing this requires either:

  1. A project-wide fl::aligned_alloc change to abort/assert on failure, OR
  2. Refactoring every singleton factory to return fl::optional<fl::shared_ptr<T>>.

Both are out of scope for a Phase 2/3a additive PR; the risk profile of my code is identical to the surrounding codebase. Worth a follow-up issue if not already tracked.

#pragma once -> FastLED compiler control macros (Minor x4: rmt_4, rmt_5, i2s_spi, ichannel.h)
The cited rule appears to be a hallucination. I checked:

  • src/fl/stl/compiler_control.h:1 itself uses #pragma once.
  • Every existing channels header uses #pragma once (bus.h, bus_traits.h, channel.h, channel_events.h, chipset_helpers.h, config.h, data.h, driver.h, id_tracker.h, ...).
  • No FASTLED_BEGIN_HEADER / FL_HEADER_BEGIN / FL_COMPILER_CONTROL_HEADER macros exist in compiler_control.h.

#pragma once is the established codebase convention. Changing 4 of my new headers to a non-existent macro pair would introduce inconsistency, not fix it.

Verification after squash

  • bash lint clean.
  • bash test --cpp passes 303/303.

…3a of #2428)

Adds a non-template polymorphic anchor `fl::IChannel` so ChannelEvents callbacks
keep working after `Channel<Bus, Chipset>` becomes a template in Phase 3b.
Pure API surface refactor -- no behavior changes.

- New: src/fl/channels/ichannel.h. Minimal ABC with virtual `id()` and `name()`,
  noexcept special members, non-copyable/movable. Holds the public surface that
  any callback might reasonably want.
- Channel now derives from CPixelLEDController<RGB> AND IChannel; existing
  `id()` / `name()` accessors marked `override`.
- ChannelEvents callbacks change from `function_list<void(const Channel&, ...)>`
  to `function_list<void(const IChannel&, ...)>`. Callsites that fire events
  pass `*this` which upcasts implicitly via the new inheritance.
- Test/doc lambdas migrated: tests/fastled_core.cpp EventTracker stores
  `const IChannel*`; lambdas in fastled_core.cpp, fl/channels/driver.cpp,
  fl/chipsets/ucs7604.cpp updated. README and FastLED.h docstrings refreshed.

Also fixes pre-existing KBI checker failures in test.py (lines 186/193/211)
flagged by lint -- the test-lock fix from #2432 introduced try-except blocks
catching Exception without KeyboardInterrupt re-raise. Added the standard
`except KeyboardInterrupt as ki: handle_keyboard_interrupt(ki)` clause before
each `except Exception`. Per CodeRabbit feedback on PR #2435, the cleanup
intentionally suppresses (does NOT re-raise) KeyboardInterrupt because:
- _release_held_build_locks() is best-effort cleanup called by deadman_timer
  and watchdog_timer, both of which call os._exit() unconditionally afterward.
- Re-raising would short-circuit the os._exit() and defeat the watchdog.

Verification:
- bash lint clean.
- bash test --cpp passes (303/303).
- ChannelEvents tests verified: pointer-identity comparisons
  `tracker.mLastChannel == channel.get()` still work because Channel inherits
  from IChannel (implicit upcast).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees force-pushed the feat/channels-bus-traits-drivers branch from a84ac1b to b0f49c8 Compare May 10, 2026 01:42
@zackees
zackees merged commit 3d295fc into master May 10, 2026
5 of 6 checks passed
@zackees

zackees commented May 10, 2026

Copy link
Copy Markdown
Member Author

@zackees teensy41 failure is pre-existing on master — same PROGMEM section type conflict ('RainbowColors_p' causes a section type conflict with 'fl::sinCosPairedLut') failing on every master CI run since at least commit ebb48e6 (5+ commits ago). Unrelated to IChannel changes here.

Filed as follow-up PR per your instruction: #2436. The fix special-cases FL_PROGMEM to expand to nothing on Teensy 4 (__IMXRT1062__) — Teensy 4 has a unified address space and the linker script places .rodata in flash automatically, so the section attribute is unnecessary and is the sole cause of the conflict.

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-bus-traits-drivers 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.

1 participant