Skip to content

Meta: convert all legacy addLeds controllers to the slim bridge (all platforms) #4580

Open
9 of 11 issues completed

Description

@zackees

Meta issue for converting every legacy FastLED.addLeds<>() controller (clockless and clocked, all platforms) to the slim bridge format. It was split out of #2856 (ESP32-S3 binary-size Batch 3) because the scope outgrew that issue. The work started as draft #4576.

Directive (2026-09-24): convert every legacy clockless and clocked controller to the slim bridge

Decision: every legacy FastLED.addLeds<>() controller, clockless and clocked (SPI), on every platform, moves to the slim bridge format. ChannelManager stays the single back-end entry point. The legacy controller stops being an fl::Channel.

The slim bridge format

  • The legacy controller is a plain CPixelLEDController<RGB_ORDER>. It does not inherit fl::Channel, and it is not created through TypedChannel::create() or held in a static ChannelPtr.
  • It owns one ChannelData. The encode buffer is cleared and refilled every frame (clear() keeps capacity), so the show path allocates nothing after the first frame.
  • showPixels() encodes with the compile-time PixelController<RGB_ORDER>, then enqueues the ChannelData on the bus driver (BusTraits<Bus::X>::instance()).
  • The constructor calls BusTraits<Bus::X>::registerWithManager(), which is idempotent. ChannelManager then owns the frame: the begin-frame wait, the end-frame show() and the async drain. Legacy and Channel API strips share one back end and one async model.
  • Not linked for a legacy sketch: the fl::Channel object, channel events, dynamic driver resolution, and the runtime RGB-reorder / PixelIteratorAny pipeline.
  • Legacy addLeds loses: colour-management profiles, 5-channel RGBWW, channel events and dynamic driver fallback. These remain on FastLED.add(Channel).

Evidence (draft #4576, ESP32 RMT5 ClocklessIdf5)

  • Size: ESP32-S3 Blink firmware.bin 424,880 → 402,352 B (−22,528 B); symbol flash −19,678 B.
  • Where the saving comes from: the fl::Channel object (−7,963 B), logging (−3,029 B), the controller ctor / static init (−2,198 B), channel events (−2,039 B) and the duplicate RGB pipeline (−1,181 B). ChannelManager itself is kept.
  • Hardware (ESP32-C6, AutoResearch):

Controllers to convert

Clockless (ESP32 family, src/platforms/esp/clockless.h)

Clocked / SPI chipsets (src/FastLED.h, FASTLED_SPI_USES_CHANNEL_API: ESP32, Teensy 4.x, RP2040/2350)

  • The four addLeds<ESPIChipsets CHIPSET, DATA_PIN, CLOCK_PIN, ...> overloads, covering APA102, SK9822, HD107, HD108, WS2801, LPD8806 and the rest. Today each builds a full fl::Channel via TypedChannel<B, SpiChipsetConfig, B_WHICH>::create() held in a static ChannelPtr. Replace them with a slim templated SPI controller that owns a ChannelData built from SpiChipsetConfig / SpiEncoder and enqueues on the SPI bus driver.

Other channel-capable platforms (Teensy 4.x, RP, STM32, SAMD, NRF52, LPC). Audit each legacy controller against the same format. Several already own a ChannelData (stub, WASM, LPC). Each still needs the check that it registers with ChannelManager rather than enqueuing into an unflushed driver.

Follow-up once no legacy path depends on it: remove the legacy-only machinery from fl::Channel:

  • the CPixelLEDController base;
  • the mDriverPreBound flag;
  • RegistrationMode::DeferRegister;
  • the legacy-only busKeepAlive path.

Scope: every platform with a clockless controller (2026-09-24)

The directive is not ESP32-only. Every legacy addLeds<> clockless controller on every platform moves to the shared slim-bridge template (fl::SlimBridgeController<..., DriverTraits>, see Testing plan → T0). So do the clocked SPI addLeds overloads.

DriverTraits come in two kinds. This keeps small targets small:

  • Bridged: platforms with a channel back end. DriverTraits wraps BusTraits<Bus::X>, registers with ChannelManager, and is async.
  • Direct: bit-bang / inline-asm platforms with no channel driver (AVR, ATtiny, ESP8266, K20, and so on). DriverTraits transmits synchronously inside showPixels() and links no ChannelManager, ChannelData or shared_ptr.
    • The goal is one controller structure and one conformance suite everywhere, with no flash increase on those targets. Check it with same-SHA bash bloat on an AVR (uno) and an ATtiny board before converting them.
    • Open decision: whether "Direct" platforms convert now or are exempted. The inventory below lists them either way.

Exhaustive inventory (62 controller files, from master at 2ea73441fe)

Found by scanning src/platforms/** for classes deriving CPixelLEDController or fl::Channel that implement clockless / WS281x-style output. The same scan is the lint's detection rule below.

Heavy: an fl::Channel subclass or built as a Channel. Convert to Bridged.

  • src/platforms/esp/32/drivers/parlio/clockless_parlio_esp32.h (ClocklessPARLIO)
  • src/FastLED.h clocked addLeds<ESPIChipsets...> ×4 (TypedChannel::create + static ChannelPtr), where FASTLED_SPI_USES_CHANNEL_API is set: ESP32, Teensy 4.x, RP2040/2350.

Slim-shaped, but the driver is never registered with ChannelManager. These are the B1 bug class: they must register, then move onto the template.

  • src/platforms/esp/32/drivers/rmt/rmt_4/idf4_clockless_rmt_esp32.h (ClocklessIdf4)
  • src/platforms/esp/32/drivers/spi/idf5_clockless_spi_esp32.h (ClocklessSPI)
  • src/platforms/arm/lpc/clockless_channel_lpc.h
  • src/platforms/arm/lpc/clockless_channel_lpc_uart_dma.h
  • src/platforms/stub/clockless_channel_stub.h
  • src/platforms/stub/spi_channel_stub.h
  • src/platforms/wasm/clockless_channel_wasm.h
  • src/platforms/wasm/spi_channel_wasm.h

For the stub and WASM entries, first verify how they flush today. The stub comment says it "bypasses ChannelManager entirely", so it may self-flush.

Compliant, pending the template extraction

Pure legacy: no channel back end. Direct traits, or exempted per the open decision.

Group Files
AVR / ATtiny avr/clockless_avr.h; avr/attiny/clockless_blocking.h; avr/attiny/clockless_blocking_controller.h
Shared / fallback shared/clockless_blocking.h (ClocklessBlockingGeneric); stub/clockless_stub_generic.h (ClocklessController, ClocklessBlockController); adafruit/clockless.h; neopixelbus/clockless.h (×2)
ESP8266 / ESP32 block esp/8266/clockless_esp8266.h; esp/8266/clockless_block_esp8266.h; esp/8266/fastled_esp8266_uart.h; esp/32/clockless_block_esp32.h
Teensy 3.x / LC / K20 / K66 / KL26 arm/teensy/teensy31_32/{clockless_arm_k20, clockless_block_arm_k20 (×2), octows2811_controller, smartmatrix_t3, ws2812serial_controller}.h; arm/teensy/teensy36/{clockless_arm_k66, clockless_block_arm_k66 (×2)}.h; arm/teensy/teensy_lc/clockless_arm_kl26.h; arm/k20/{clockless_block_arm_k20 (×2), octows2811_controller, smartmatrix_t3, ws2812serial_controller}.h; arm/k66/{clockless_arm_k66, clockless_block_arm_k66 (×2)}.h; arm/kl26/clockless_arm_kl26.h
Teensy 4 / MXRT1062 arm/teensy/teensy4_common/{clockless, clockless_arm_mxrt1062 (BitBang), block_clockless_arm_mxrt1062, octows2811_controller}.h; arm/mxrt1062/{clockless_arm_mxrt1062, block_clockless_arm_mxrt1062, octows2811_controller}.h. The ObjectFLED proxy has a channel engine (ChannelEngineObjectFLED), so it is a Bridged candidate.
RP2040 / RP2350 arm/rp/rpcommon/clockless_rp_pio.h; clockless_rp_pio_parallel.h. RP has channel engines (PIO/UART/SPI), so these are Bridged candidates.
SAMD / SAM arm/d21/clockless_arm_d21.h; arm/d51/clockless_arm_d51.h; arm/sam/clockless_arm_sam.h; arm/sam/clockless_block_arm_sam.h
STM32 / GIGA arm/stm32/clockless_arm_stm32.h (×2); arm/giga/clockless_arm_giga.h
nRF arm/nrf51/clockless_arm_nrf51.h; arm/nrf52/clockless_arm_nrf52.h
LPC (non-channel) arm/lpc/clockless_arm_lpc.h; arm/lpc/clockless_arm_lpc_plu.h
Other apollo3/clockless_apollo3.h; arm/renesas/clockless_arm_renesas.h; arm/mgm240/{clockless_arm_mgm240, clockless_ezws2812_39mhz, clockless_ezws2812_78mhz, clockless_ezws2812_gpio, clockless_ezws2812_spi}.h; ci13xx/clockless_ci13xx.h

FASTLED_HAS_CHANNELS is 1 for ESP32, Teensy 4.x, RP, STM32, SAMD and NRF52. For those platforms, check whether a channel driver already exists to back a Bridged conversion. STM32, SAMD and NRF52 legacy clockless controllers do not use one today.

Tracking: one sub-issue per conversion unit

Progress is tracked by native sub-issues of this meta issue. There is no checked-in lint, and master is never turned red by this work. Each sub-issue:

  • names the controller files it covers, from the inventory above;
  • must pass the T1 conformance suite for its DriverTraits;
  • must carry a same-SHA bash bloat before/after;
  • must include AutoResearch evidence where hardware is available.

Optional: a contributor may keep an uncommitted, local-only scan while working, using the detection rule "class derives CPixelLEDController/Channel, is clockless-style, and is not on fl::SlimBridgeController". It must not be checked in.

The meta issue closes when every sub-issue is closed.

Known gaps of the slim bridge (audit of draft #4576, 2026-09-24)

This is a register, not a fix list. Each conversion PR decides which gaps to close and which to accept and document.

Legend:

A. Behaviour gaps in the slim controller itself (idf5_clockless.h)

# Gap Status Impact Verified
A1 Disabled / non-exclusive driver not honoured. Channel::submitFrame checked ChannelManager::driverStatus() and skipped a disabled driver with a one-shot error. The slim controller always enqueues. After setExclusiveDriver(other) or setDriverEnabled("RMT", false), onEndFrame skips show(), the buffer stays in use, and the next waitForReady() stalls until its 1 s timeout. Regression Stall and no LED output, silently code; stall inferred
A2 clearAllDrivers() / removeDriver() orphan the driver. The controller reaches the driver through the BusTraits<Bus::RMT> singleton, not the registry. After the RMT driver leaves mDrivers (e.g. FastLED.clear(CHANNEL_ENGINES)), data is still enqueued but never shown. Channel re-resolved the driver each frame when it was not pre-bound, but the old pre-bound ClocklessIdf5 also cached it. Regression, partly pre-existing No output after a clear, silently code; inferred
A3 RGBWW dropped. showPixels builds pixels.as_iterator(getRgbw()) and never passes getRgbww(), so CLEDController::setRgbww() on a legacy strip is ignored. The old path passed both to ReorderingPixelIteratorAny, and writeWS2812 has an RGBWW branch. Regression Wrong bytes for 5-channel strips code
A4 Colour profile / colour pipeline ignored. Channel::encodeFrame fed mPipeline (StreamingPipelineQ16, FL_COLOR_PROFILE_RUNTIME) from the controller's profile settings (bindStaticEmitterProfile, mSettings.mColorProfile). The slim path never reads them. This includes .fled-declared colour (#4460). Regression, but only for legacy strips that bind a profile; none by default Colour output differs when a profile is bound code
A5 Pixel-format tag not set. Channel called ChannelData::setPixelFormat(RGB/RGBW/RGBWW) each frame; the slim path never does. No ESP32 driver reads the tag. LPC SCT-DMA and Teensy ObjectFLED do read it, so their conversions must set it. Regression (latent on ESP32) None on ESP32; wrong on LPC/Teensy if copied as-is code
A6 Dither phase semantics. Channel advanced mDitherPhase only when a driver accepted a frame (#4347/#4452). The slim path uses classic legacy CPixelLEDController dithering, the same as RMT4 and pre-channel FastLED. The two differ only on dropped frames. There is no ditherPhase() introspection. Regression vs. interim Channel path Minor temporal-dither difference code
A7 Per-frame channel events no longer fire. onChannelDataEncoded and onChannelEnqueued fired for the old Channel-backed legacy strip. onChannelAdded never did, because it used addToList(). No in-tree consumer depends on them for legacy strips. Regression (API surface) Only for user listeners code
A8 Silent frame drop under backpressure. When the buffer is in use and waitForReady() fails, the slim path returns with no log. Channel::waitForInUseBuffer warned. Regression (diagnostics) Harder to debug code
A9 No per-frame null / canHandle() guard. Allocation failures (e.g. more strips than RMT channels) surface asynchronously inside the driver, not at the controller. Largely pre-existing (pre-bound path) Diagnostics code
A10 WAIT_TIME template parameter ignored. ClocklessIdf4 folds WAIT_TIME into reset_us; RMT5 does not, and neither did the old Channel-backed version. Pre-existing Latch time differs between IDF4 and IDF5 code
A11 Only the WS2812 encoder is used. Non-WS2812 clockless encoders (TM1812 RGBWW, TM1908, UCS7604, 16-bit) are not selected. The old ClocklessIdf5 also hard-coded ws2812PixelEncoder(). Pre-existing Any such chipset routed through ClocklessController on RMT5 was already WS2812-encoded code
A12 FastLED.clear(CHANNELS) does not touch legacy strips. Already-enqueued legacy data can still be shown after a clear. Pre-existing Minor inferred

Not gaps (checked):

  • Plain WS2812 RGB/RGBW bytes: identical; both paths call writeWS2812.
  • Power-limiter codec policy: powerChannelCodecPolicy never matched legacy strips, which are not in CFastLED::channels(), so it is unchanged.
  • Classic power limiter: unchanged.
  • Static-init / PSRAM timing: same as Channel.
  • Buffer reuse: clear() keeps capacity, so there is no steady-state allocation.
  • ChannelManager poll semaphore: still linked in the bridged version.
  • WASM strip enumeration: uses EngineEvents, not Channel.
  • AutoResearch legacy harness: never casts to Channel.

B. Gaps found in the controllers still to convert

# Finding Verified
B1 ClocklessIdf4 (RMT4) and ClocklessSPI (ESP32-S2 default) never register with ChannelManager. They talk to their drivers directly (comment: "bypass ChannelManager", Phase 5c of #2428). ChannelManager::onEndFrame is the only caller of driver->show() in the tree, so their enqueued data is likely never transmitted. code; hardware repro still needed (IDF4 build, ESP32-S2)
B2 LPC clockless_channel_lpc*.h is already slim but needs the same registration audit as B1. not yet checked
B3 ClocklessPARLIO is the last ESP32 clockless Channel subclass. ChannelDriverPARLIO groups and batches by ChannelData timing, so the conversion looks mechanical. DMA scratch-buffer ownership relative to the Channel lifetime is unverified. code; inferred low risk
B4 Clocked/SPI addLeds<ESPIChipsets...> (FastLED.h ~1150-1235). A slim version must replicate: per-chipset SpiEncoder selection; APA102/SK9822/HD107/HD108 brightness-field handling (#4441, #4457, #4464); HD108's GRB default; Esp32SpiBus host selection; end-frame bytes (spi_channel_adapter.*). The least-explored target. partially read
B5 Teensy 4 ObjectFLED legacy ClocklessController uses its own draw-buffer proxy, not ChannelData, so it needs a full conversion. ChannelEngineObjectFLED reads getPixelFormat() (see A5). code
B6 RP2040/2350 legacy clockless (clockless_rp_pio*.h) predates the channel system and has no ChannelData integration. Per the agent audit, STM32/SAMD/NRF52 legacy controllers also look pre-channel. Out of scope until a ChannelData driver exists for each. inferred

C. Verification / coverage gaps

Stale comments to update when converting:

  • examples/AutoResearch/LegacyClocklessProxy.h:6, AutoResearchTimingDrift.h:6 and AutoResearchTest.cpp:1651 describe the path as ... -> ClocklessIdf5 -> Channel.
  • channel_typed.h:61 lists ClocklessIdf5 as a Channel consumer.

Testing plan: catch every gap in a host unit test

Goal: every item in the gap register (A1-A12, B1-B5, C1-C2) has a host unit test (bash test) that fails when the gap exists. Regressions we choose to fix go RED → GREEN; gaps we choose to accept get a test that pins the accepted behaviour, so a later change is a visible, deliberate decision.

T0. Prerequisite: one shared, host-compilable slim controller

Today each platform hand-writes its own copy of the legacy controller:

  • ESP32 ClocklessIdf5 (RMT5), ClocklessIdf4 (RMT4) and ClocklessSPI;
  • the host stub clockless_channel_stub.h;
  • LPC clockless_channel_lpc*.h.

The ESP32 ones compile only with FASTLED_RMT5 / ESP-IDF, so no host test exercises them (C1), and the copies have already drifted (B1, A10).

  • Extract the controller into one template, e.g. fl::SlimBridgeController<DATA_PIN, TIMING, RGB_ORDER, WAIT_TIME, DriverTraits> in src/fl/channels/slim_bridge_controller.h, with no platform includes.
    • DriverTraits supplies instance(), instancePtr(), registerWithManager() and the driver name. These are BusTraits<Bus::X> on device, and a test traits type on host.
    • All the gap-relevant logic lives here, so a host test of it tests the device code:
      • registration;
      • the driver-status check;
      • the in-use wait;
      • pixel-format tagging;
      • RGBW/RGBWW selection;
      • the encoder;
      • WAIT_TIME → reset_us;
      • buffer reuse.
  • Every platform legacy controller (ClocklessIdf5, ClocklessPARLIO, ClocklessIdf4, ClocklessSPI, LPC, stub) becomes a thin alias or subclass that only picks DriverTraits.
  • Host test harness:
    • TestDriverTraits bound to a capturing IChannelDriver mock (extend ByteCapturingMockEngine / StatefulMockDriver in tests/fl/channels/) that records enqueue(), show(), poll() and waitForReady() calls and can be forced BUSY or failing;
    • plus an integration variant bound to the real ChannelEngineRMT over the RMT5 peripheral mock (rmt5_peripheral_mock, as tests/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp already does).
  • Conformance suite: write the tests below once, as a templated suite run over every DriverTraits in use. A new conversion must pass the same suite, which prevents a repeat of the RMT4/SPI registration drift (B1).

T1. Controller behaviour tests (tests/fl/channels/slim_bridge_controller.cpp)

Test Catches Assertion
Constructor registers the driver B1, B2 After constructing a controller, ChannelManager::instance() lists the driver by name. Constructing two controllers registers it once (idempotent).
FastLED.show() flushes B1 Frame N: mock records enqueue then show exactly once; onBeginFrame waits and onEndFrame shows. Would fail for today's RMT4/SPI copies.
Disabled driver is honoured A1 setDriverEnabled(name, false) / setExclusiveDriver(other): showPixels does not enqueue, no waitForReady stall (bounded fake clock or call count), one diagnostic emitted. Re-enable → next frame enqueues.
Driver removed / cleared A2 After removeDriver() / clearAllDrivers(), either the controller re-registers on the next frame or it skips the enqueue. Assert whichever is chosen, and that there is no stuck in-use buffer.
Plain RGB bytes parity baseline 3 pixels, GRB: bytes equal a golden vector and equal the fl::Channel encode of the same pixels (reuse the #4566 showOnce4566 helper).
RGBW bytes and tag A5 With setRgbw(...): 4 bytes/pixel, ChannelData::getPixelFormat() == RGBW, and bytes match the Channel path.
RGBWW A3 With setRgbww(...): 5 bytes/pixel, tag RGBWW, and bytes match the Channel path. If RGBWW is declared unsupported on legacy, assert the documented behaviour (e.g. rejected with a warning) instead.
Colour profile A4 Bind a static emitter profile on the legacy controller. Assert either pipeline output equal to the Channel path, or the documented "ignored + warned once" behaviour. It must not silently differ.
Dither phase A6 With BINARY_DITHER over K frames, including a dropped frame (driver BUSY), assert the phase sequence. Pin legacy semantics, or assert "advances only on accepted frame" if we adopt #4347 semantics.
Events A7 Subscribe to ChannelEvents::onChannelDataEncoded / onChannelEnqueued. Assert the chosen contract: fired, or documented as not fired for legacy strips.
Backpressure A8, A9 Mock stays BUSY: showPixels returns without enqueue, a diagnostic is emitted once (not per frame), and it recovers when the mock goes READY.
WAIT_TIME A10 WAIT_TIME > chipset reset: the enqueued ChannelData timing reset_us == WAIT_TIME, matching RMT4. Or pin "ignored" if we accept it.
Chipset encoder selection A11 Instantiate via a non-WS2812 clockless chipset template (e.g. UCS7604, TM1814 RGBW). Assert the bytes equal that chipset's Channel encoder, or pin the WS2812-only limitation.
FastLED.clear(CHANNELS) / reset A12 A frame is enqueued but not shown, then clear(CHANNELS): assert the documented outcome (dropped or shown).
Buffer reuse, no per-frame allocation acceptance After frame 1, mChannelData->getData() keeps the same data() pointer and capacity() across 100 frames of the same size. Use the allocation counter too, if available.
showColor / clearLeds C2 Both route through showPixels and produce the expected bytes.

T2. Multi-strip and mixed-API tests (integration, real ChannelEngineRMT over the RMT5 mock)

Test Catches Assertion
N legacy strips on different pins C2 Every strip's bytes reach the mock peripheral in one FastLED.show().
More legacy strips than RMT channels C2 (and the #4573 READY-race class) With Rmt5PeripheralMock::setMaxChannels(k) and k+2 strips, every strip transmits once per frame and the driver ends READY. poll() never reports READY while a strip is transmitting.
Legacy + FastLED.add(Channel) in one frame C2 Both strips transmit exactly once per frame through the same ChannelManager flush, with no double show().
Legacy vs Channel byte parity on RMT5 C2 Same pixels through ClocklessIdf5 (slim) and a Channel-API strip: identical bytes at the peripheral mock.

T3. Per-platform conformance (B3-B5)

  • PARLIO, clocked SPI, LPC, Teensy ObjectFLED: run the T1 suite with each DriverTraits. The SPI controller adds golden-byte tests per SpiChipset:

    • APA102/SK9822 brightness field and end frame;
    • HD107/HD108 16-bit and GRB default;
    • WS2801;
    • Esp32SpiBus host selection;

    each asserted equal to today's TypedChannel output before the conversion lands.

  • LPC SCT-DMA and ObjectFLED tests must assert the pixel-format tag (A5), because those drivers read it.

T4. Hardware and CI backstops (not a replacement for T1-T3)

Suggested order

  1. T0 extraction plus the T1 registration and flush tests. These should go RED on RMT4/SPI today, proving B1.
  2. The rest of T1 and T2 against the RMT5 slim controller from exp(esp32): legacy RMT5 addLeds off fl::Channel, still bridged via ChannelManager (-22 KB Blink) #4576. This pins or fixes A1-A12 before merge.
  3. T3 per conversion PR.

Acceptance per controller

  • Same-SHA, same-toolchain bash bloat before and after on a representative board. Record firmware.bin and symbol deltas.
  • AutoResearch on hardware for the legacy path, and for the Channel API on the same build.
  • No per-frame allocation on the show path.
  • Passes the T1 conformance suite with its DriverTraits (see Testing plan). Each gap in the register is either fixed (RED → GREEN) or pinned as accepted behaviour.

Sub-issues

Sub-issues

9 of 11 Issues completed
Loading 11 sub-issues

Activity

  1. 9 remaining items

  2. zackees commented on Sep 25, 2026

    @zackees
    MemberAuthor

    The non-channel platforms are no longer exempt outright. #4588-#4597 and #4599 are reopened under the follow-up meta #4601, which decides per platform, by measurement, whether each needs the slim bridge. This meta issue keeps #4581-#4587 and #4598.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions