Repository navigation
fix(core): flush channel drivers on direct CLEDController::showLeds (#2371) - #2377
Conversation
…wLeds Fixes #2371. Since the ESP32 clockless path moved onto the `ChannelManager` architecture (`ClocklessIdf5` inherits from `fl::Channel`), `Channel::showPixels()` only *enqueues* encoded pixel data on the channel driver; the actual hardware flush is driven by `ChannelManager::onEndFrame()`, which `FastLED.show()` triggers via `EngineEvents::onEndFrame()`. The direct per-controller path (`FastLED[0].showLeds(255)` / `CLEDController:: showLeds()`) never emitted those frame events, so it queued bytes but never told the driver to transmit — the indexed API effectively stopped producing output on channel-backed platforms, even though `FastLED.show()` worked. Fix: have `CLEDController::showLeds()` bracket the begin/show/end sequence with `onBeginFrame()` and `onEndFrame()` / `onEndShowLeds()`, matching the flush that `CFastLED::show()` already performs. Gated on `FASTLED_HAS_ENGINE_EVENTS` so tiny/low-memory builds keep the lightweight inlined path (no `EngineEvents`, no `ChannelManager` pulled in). Why here vs `Channel::showLeds()`: other channel-driver-backed controller wrappers (ESP32 RMT4, clockless-SPI paths that are `CPixelLEDController` subclasses rather than `fl::Channel` subclasses) have the same enqueue- without-flush structure; fixing in the base `CLEDController` covers all of them. Also in this change, needed to unblock compilation after picking up master: - `src/fl/stl/span.h`: delete the single-argument `explicit span(T *data)` constructor for the static-extent specialization. It is not in `std::span<T, N>` and created an ambiguity against `span(T (&arr)[N])` for `fl::span<const CRGB, 32>(pal.entries)` in `colorutils.cpp.hpp` under clang 21. The C-array constructor already provides the compile-time-sized case without a redundant runtime length; callers that previously used the pointer-only form must use the `(pointer, size)` form. Tests in `tests/fl/channels/driver.cpp`: - Existing `Channel transmission` test: drop the manual `mockEngine->show()` and verify transmission happens via the direct `channel->showLeds(255)` path. - New `CLEDController direct showLeds flushes channel drivers`: invokes `controller->showLeds(255)` on the `CLEDController*` obtained via `asController()` and confirms both `enqueue()` and `show()` fire on the mock driver. - New `CLEDController clearLeds flushes cleared channel data`: exercises the clear-then-show compatibility path and confirms LEDs are zeroed and flushed in one call. - `FastLED.show() with channels`: drop the in-test debug `FL_WARN`s; assert directly that `FastLED.show()` both enqueues and transmits without a manual `mockEngine->show()`.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis pull request addresses a bug in the multiple instance interface where direct calls to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
📊 Header Compilation PerformanceTotal Time: 1183.87ms Top 5 Slowest Headers
Warnings
Full Report |
Fixes #2371.
Summary
FastLED[0].showLeds(255)on channel-backed platforms (e.g. ESP32-S3 RMT5 /ClocklessIdf5) stopped producing output onmaster: the call queued encoded pixel bytes on theChannelManagerdriver but never told the driver to transmit, because that flush is normally driven by the frame-end event thatFastLED.show()emits.CLEDController::showLeds()withEngineEvents::onBeginFrame()/onEndFrame()/onEndShowLeds(), gated onFASTLED_HAS_ENGINE_EVENTSso tiny/low-memory targets keep the lightweight inlined path with noEngineEvents/ChannelManagerpulled in.e713d6f9f3(Add CRGB16 palette lookup API): delete the non-std::spansingle-argumentexplicit span(T *data)constructor on the static-extent specialization — it was ambiguous withspan(T (&arr)[N])under clang 21. The C-array constructor already handles the compile-time-sized case without a redundant runtime length, matchingstd::span<T, N>::span(std::type_identity_t<T>(&)[N]).Design notes
Fixing at
CLEDController::showLeds()(notChannel::showLeds()) because other channel-driver-backed controller wrappers (ESP32 RMT4, clockless-SPI paths that areCPixelLEDControllersubclasses rather thanfl::Channelsubclasses) share the same enqueue-without-flush structure — the base-class fix covers all of them.Global batching is unaffected:
FastLED.show()callsshowLedsInternal()on each controller (not publicshowLeds()), then fires frame events once at the end.See #2371 for the full investigation and the design-note comment.
Test plan
bash test --cpp fl/channels/driver.cpp— existingChannel transmissiontest updated to drop the manualmockEngine->show()and exercise directchannel->showLeds(255); two new test cases covercontroller->showLeds(255)andcontroller->clearLeds()viaasController();FastLED.show() with channelssimplified to assert both enqueue and transmit fire without a manual mockshow().bash test --cpp fl/gfx/colorutils_palette.cpp— confirms the span ambiguity fix keepsColorFromPaletteHDinstantiations working.bash test --cpp fl/stl/span— span unit tests.bash lint --cpp.Related
Filed #2376 for the pre-existing
#pragma once+ PCH redefinition issue on Windows that shows up withbash test --cpp(full suite) forfl/cled_controller.handfl/gfx/colorutils.h. Not in scope for this PR and reproduces onmasterindependent of this change.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Breaking Changes
fl::spanstatic-extent constructor updated—pointer-based construction removed and replaced with array-based construction.Improvements
Tests