Repository navigation
feat(channels): per-driver BusTraits specializations + DefaultBus (Phase 2 of #2428) - #2431
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
…ase 2 of #2428) Adds BusTraits<Bus::X> specializations for all 13 first-party channel drivers across ESP32, Teensy 4.x, and shared platforms. Each specialization provides a Driver type alias, a lazy singleton accessor that constructs the driver on first call, and one or more BusSupports<Bus::X, Chipset> true_type declarations marking which chipset families the driver can drive. Each driver's bus_traits.h is wired into its sibling _build.cpp.hpp unity-build aggregator so it parses during the platform compile. No existing code changes; no behavior changes. ESP32 specializations (10): - Bus::RMT -> ChannelEngineRMT (RMT5 path) - Bus::RMT -> ChannelEngineRMT4 (RMT4 path, mutually exclusive) - Bus::PARLIO -> ChannelDriverPARLIO (P4/C6/H2/C5) - Bus::SPI -> ChannelEngineSpi (clockless-over-SPI) - Bus::I2S -> IChannelDriver via createI2sEngine() (S3 LCD_CAM) - Bus::I2S_SPI -> IChannelDriver via createI2sSpiEngine() (ESP32-dev) - Bus::LCD_RGB -> IChannelDriver via createLcdRgbEngine() (P4) - Bus::LCD_SPI -> IChannelDriver via createLcdSpiEngine() (S3) - Bus::LCD_CLOCKLESS-> IChannelDriver via createLcdClocklessEngine() (S3) - Bus::UART -> ChannelEngineUART(UartPeripheralEsp) Teensy 4.x specializations (2): - Bus::FLEX_IO -> ChannelEngineFlexIO - Bus::OBJECT_FLED -> ChannelEngineObjectFLED Shared (1): - Bus::BIT_BANG -> BitBangChannelDriver (cross-platform fallback, supports both clockless and SPI chipsets) DefaultBus<Chipset> per-platform specializations added to fl/channels/bus.h: - ESP32-P4/C6/H2/C5 clockless -> Bus::PARLIO (matches priority 4 in channel_manager_esp32.cpp.hpp) - Other ESP32 variants clockless -> Bus::RMT - ESP32-S3 SPI -> Bus::LCD_SPI - ESP32-dev SPI -> Bus::I2S_SPI - Teensy 4.x clockless -> Bus::OBJECT_FLED - Other platforms intentionally leave DefaultBus<SpiChipsetConfig> undefined, so the templated API surfaces a clear "specify Bus::X explicitly" error. Verification: - bash lint clean - bash test --cpp passes (221/221, fingerprint cache) - ESP32 platform compilation deferred to Phase 3 verification (the new headers are dormant in this PR -- nothing names BusTraits<Bus::X>::instance() yet, so the lazy singletons stay uninstantiated even though they parse). C++11-clean throughout (matches project floor in meson.build:5). All shared_ptr-returning factory functions are reused from the existing driver headers; no redundant declarations. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees
force-pushed
the
feat/channels-bus-traits-drivers
branch
from
May 9, 2026 23:13
a0cb86f to
82849a6
Compare
2 of 3 tasks
zackees
added a commit
that referenced
this pull request
May 10, 2026
…3a of #2428) (#2433) 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]>
This was referenced May 10, 2026
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 of the compile-time channel-bus binding work tracked in #2428. Adds
BusTraits<Bus::X>specializations for all 13 first-party channel drivers (ESP32 + Teensy 4.x + shared bit-bang) and per-platformDefaultBus<Chipset>specializations.Stacked on top of #2429 (Phase 1:
fl::Busenum + foundational traits). Re-target this PR's base tomasteronce #2429 merges.What's in this PR
13 per-driver
bus_traits.h(1 per driver subdirectory)Bus::RMT(RMT5)ChannelEngineRMTplatforms/esp/32/drivers/rmt/rmt_5/bus_traits.hBus::RMT(RMT4)ChannelEngineRMT4platforms/esp/32/drivers/rmt/rmt_4/bus_traits.hBus::PARLIOChannelDriverPARLIOplatforms/esp/32/drivers/parlio/bus_traits.hBus::SPIChannelEngineSpiplatforms/esp/32/drivers/spi/bus_traits.hBus::I2SIChannelDriver(factory)platforms/esp/32/drivers/i2s/bus_traits.hBus::I2S_SPIIChannelDriver(factory)platforms/esp/32/drivers/i2s_spi/bus_traits.hBus::LCD_RGBIChannelDriver(factory)platforms/esp/32/drivers/lcd_cam/bus_traits.hBus::LCD_SPI+Bus::LCD_CLOCKLESSIChannelDriver(factory)platforms/esp/32/drivers/lcd_spi/bus_traits.hBus::UARTChannelEngineUART(with peripheral)platforms/esp/32/drivers/uart/bus_traits.hBus::FLEX_IOChannelEngineFlexIOplatforms/arm/teensy/teensy4_common/drivers/flexio/bus_traits.hBus::OBJECT_FLEDChannelEngineObjectFLEDplatforms/arm/teensy/teensy4_common/drivers/objectfled/bus_traits.hBus::BIT_BANGBitBangChannelDriverplatforms/shared/bitbang/bus_traits.hEach
bus_traits.his wired into the sibling_build.cpp.hppaggregator so it parses during the platform compile. The headers are otherwise dormant — nothing namesBusTraits<Bus::X>::instance()yet (Phase 3 will), so the lazy singletons stay uninstantiated.DefaultBus<Chipset>per-platform specializations insrc/fl/channels/bus.hBus::PARLIO(matches priority 4 inchannel_manager_esp32.cpp.hpp).Bus::RMT.Bus::LCD_SPI.Bus::I2S_SPI.Bus::OBJECT_FLED.DefaultBus<SpiChipsetConfig>undefined so the templated API surfaces a clear "specify Bus::X explicitly" compile error.Pattern detail
All
instance()accessors use a Meyers singleton holding afl::shared_ptr<Driver>— the existingcreate*Engine()factories ormake_shared<Driver>calls are reused unchanged. NamingBusTraits<Bus::X>::instance()from any TU is what causes the linker to keep that driver's TU alive (the tree-shaking lever Phase 4/5 will pull).C++11-clean throughout (no
autotemplate params, no fold expressions, no variable templates).Why
Foundation for the templated
Channel<Bus, Chipset>andadd<Bus>(cfg)API ratified in #2428 — drivers will only link when theirBusvalue is named. Eliminates the 344 KB → 783 KB binary bloat from #2421 / #2420 (Phase 5) and makes bus/chipset mismatches compile errors.Verification
bash lintclean.bash test --cpppasses (221/221)._build.cpp.hpponly verifies they parse, not that the singletons run correctly. Phase 3 will exercise them throughChannel<B, Chipset>::showPixels().Note on flaky test infrastructure
While running verification I hit the issue filed as #2430 — a previous test process held the
libfastled_buildSQLite lock for 800+ seconds, blocking new runs for 120 s. Worked around bytaskkill. The test results above are from a clean run after recovery.Test plan
tests/fl/channels/bus_traits.cpp) still passes.BusTraits<Bus::STUB>::instance().enqueue(...)end-to-end via the templatedChannel<>::showPixels().Related
🤖 Generated with Claude Code