Skip to content

feat(channels): introduce IChannel ABC base for ChannelEvents (Phase 3a of #2428) - #2433

Merged
zackees merged 1 commit into
feat/channels-bus-traits-driversfrom
feat/channels-ichannel-base
May 10, 2026
Merged

zackees merged 1 commit into
feat/channels-bus-traits-driversfrom
feat/channels-ichannel-base

Conversation

@zackees

@zackees zackees commented May 9, 2026

Copy link
Copy Markdown
Member

Summary

Phase 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.

Stacked on #2431 (Phase 2). Re-target to master after Phase 2 merges.

What's in this PR

New file: src/fl/channels/ichannel.h

Minimal ABC with virtual id() and name(), FL_NOEXCEPT special members, non-copyable/movable. Holds the public surface that any callback might reasonably want to identify a channel.

Channel now derives from IChannel

Multiple inheritance: class Channel: public CPixelLEDController<RGB>, public IChannel. Existing id() / name() accessors marked override. No behavior change — the methods already returned the same types.

ChannelEvents callbacks take IChannel

  • function_list<void(const Channel&, ...)> -> function_list<void(const IChannel&, ...)> for all 7 event types.
  • Callsites in channel.cpp.hpp that fire events (events.onChannelCreated(*channel) etc.) work unchanged thanks to the implicit Channel* -> IChannel* upcast.

Tests + docs migrated

  • tests/fastled_core.cpp EventTracker::mLastChannel typed as const IChannel*; methods take const IChannel&. Pointer-identity comparison tracker.mLastChannel == channel.get() works because Channel inherits from IChannel.
  • 15 lambdas in fastled_core.cpp + 2 in fl/channels/driver.cpp + 2 in fl/chipsets/ucs7604.cpp updated to const IChannel&.
  • README.md and FastLED.h docstring examples refreshed.

Bonus: fixes pre-existing KBI lint failures in test.py

The test-lock fix from #2432 introduced three try: ... except Exception: pass blocks at test.py:186, 193, 211 without KeyboardInterrupt handlers, which the KeyboardInterrupt handler checks linter rejects. Added the standard except KeyboardInterrupt as ki: handle_keyboard_interrupt(ki); raise clause before each except Exception. Surfaced because my changes invalidated the lint cache; per project policy fix-when-encountered.

Why

Foundation step for Phase 3b (templatize ChannelConfig<Chipset> and Channel<Bus, Chipset>). Once Channel becomes templated, the event system needs a non-template type to take. Adding the IChannel ABC now lets Phase 3b focus purely on the templatization without simultaneously re-plumbing events.

Verification

  • bash lint clean.
  • bash test --cpp passes (286/286).
  • ChannelEvents test cases verify the pointer-identity comparison still works through the upcast.
  • C++11-clean throughout (no auto deduction tricks, FL_NOEXCEPT everywhere per project convention).

Test plan

  • All host tests pass.
  • EventTracker pointer-identity checks pass after IChannel migration.
  • Phase 3b will exercise Channel<B, Chipset> deriving from IChannel the same way.

Related

🤖 Generated with Claude Code

…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.

Phase 3a is purely an 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); raise`
clause before each `except Exception`.

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

Stacked on top of Phase 2 (#2431). When Phase 3b lands, Channel<B, Chipset>
will simply derive from IChannel the same way -- no further event-system
changes needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c23b597d-4c7f-4ef8-80cb-ffe3d587e726

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/channels-ichannel-base

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.

@zackees
zackees merged commit da8e588 into feat/channels-bus-traits-drivers May 10, 2026
1 check failed
@zackees
zackees deleted the feat/channels-ichannel-base 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