Repository navigation
Description
Summary
FastLED currently has two parallel hardware abstractions that are starting to overlap conceptually but not architecturally:
- TX path:
Channel->ChannelData->IChannelDriver->ChannelManager - RX path:
RxDevice->RmtRxChannel/GpioIsrRx/FlexPwmRxChannel
The overlap is now visible enough that it is worth deciding whether RX should be folded into the Channel API, or whether both TX and RX should instead sit on top of a shared lower-level device/backend layer.
My recommendation is:
Do not move RX directly into the current Channel API.
Instead, keep Channel explicitly TX/output-oriented, and introduce a shared signal-device / peripheral-backend layer below both TX and RX.
Why not put RX directly in the Channel API?
The current Channel API is strongly output-centric by design:
Channelowns LED spans, gamma, color order, screen maps, andshowLeds()/showPixels()lifecycle.ChannelDatais an encoded transmit buffer DTO.IChannelDriveris an enqueue/show/poll state machine for transmission.ChannelManageris a TX router/priority selector for output drivers.
RX does not match those semantics well:
RxDevicemodelsbegin()/wait()/decode()/getRawEdgeTimes().- RX output is captured edges / decoded bytes, not LED frames.
- RX is used by validation and autoresearch independent of any LED
Channelobject. RxDeviceType::{RMT, ISR, FLEXPWM}are transport/capture choices, not LED-strip renderers.
Trying to force RX into the current Channel API would either:
- overload
Channelwith non-output meaning, or - distort RX into an unnatural
enqueue()/show()/poll()shape.
Evidence in the current tree
Relevant files:
src/fl/channels/channel.hsrc/fl/channels/data.hsrc/fl/channels/driver.hsrc/fl/channels/manager.hsrc/fl/rx_device.hsrc/fl/rx_device.cpp.hppsrc/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.hsrc/platforms/esp/32/drivers/gpio_isr_rx/gpio_isr_rx.hsrc/platforms/shared/rx_device_native.hexamples/AutoResearch/AutoResearch*.{ino,h,cpp}
There is already a strong architectural hint that TX and RX share hardware resource concerns even though their APIs are separate:
src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hppexplicitly coordinates TX DMA policy around active RX channels.RmtMemoryManagerand related comments already treat TX and RX as consumers of the same underlying RMT resource domain.README.mddescribes the driver stack as a platform-neutral channel driver plus thin platform peripheral layer, but RX currently lives outside that layering.
So the shared concern is real, but the current Channel abstraction is the wrong level to absorb it.
Proposed refactor option
Option A (recommended): shared backend layer under both TX and RX
Add a new layer for hardware/peripheral ownership and capabilities. Example naming could be one of:
fl::signalfl::iofl::peripherals
The important part is the shape, not the exact namespace.
Suggested responsibilities:
-
Backend/resource layer
- Owns peripheral handles, DMA slots, memory pools, IRQ registration, GPIO binding, loopback capability, etc.
- Exposes capability flags like
tx,rx,clockless,spi,capture_edges,decode_assist, etc. - Centralizes cross-cutting resource arbitration such as RMT TX/RX DMA conflicts.
-
TX adapter layer
- Existing
IChannelDriverimplementations become TX adapters over the backend/resource layer. ChannelManagerremains the TX-facing router.
- Existing
-
RX adapter layer
RxDeviceimplementations become RX adapters over the same backend/resource layer.- Optionally add an
RxManagerorDeviceRegistrylater if runtime selection by capability/name becomes useful.
First migration slice
A practical incremental path:
-
Do not break public APIs first.
KeepChannel,IChannelDriver,ChannelManager, andRxDevicepublic surfaces intact. -
Extract shared resource ownership first.
Start with RMT, because it already has visible TX/RX interaction.
Create a shared RMT backend/resource object used by bothChannelEngineRMTandRmtRxChannel. -
Move arbitration logic down.
Things like DMA slot ownership, memory block accounting, loopback compatibility, and TX/RX coexistence policy should live below both APIs rather than leaking across them. -
Only after that, add a generic device registry if still useful.
That would allow future APIs like named RX backend selection or affinity, without forcing RX intoChannel.
What this buys us
- Preserves the clean meaning of
Channelas an LED output abstraction. - Gives RX a first-class architectural home instead of leaving it as a parallel one-off tree.
- Fixes the real pain point: shared peripheral/resource logic duplicated or leaked across TX/RX implementations.
- Makes future peripherals easier to model when they support both TX and RX modes.
- Avoids turning the Channels API into a catch-all abstraction for anything that touches a pin.
Non-goal
This issue is not proposing to delete RxDevice or immediately replace it with Channels API calls.
The goal is to refactor the layering so that:
Channelstays TX-facing,RxDevicestays RX-facing,- and both share the same lower-level backend/resource model where appropriate.
Related
- FastLED Channels API #2167
- ESP32-S3: I2S driver starves websockets, SPI output incorrect, Audio driver FPS impact #2254
Concrete deliverable for this issue
A good outcome here would be agreement on the target architecture and a first implementation step such as:
- extracting shared RMT TX/RX backend/resource management into a common module, or
- creating a minimal
signal/iobackend interface used by bothChannelEngineRMTandRmtRxChannel.
Activity
zackees commentedon Apr 24, 2026
Follow-up design direction is now tracked in #2397.\n\nThe updated conclusion is not to keep RX entirely outside channels, but to introduce a sibling API under l/channels/rx/** with RxChannel as the public type, while keeping the existing TX Channel TX-only and leaving RxDevice as the internal backend / compatibility layer.
zackees commentedon May 24, 2026
Closing as completed — superseded by #2397.
The architectural decision was made (per the April 24 comment in this thread): "introduce a sibling API under `fl/channels/rx/**` with `RxChannel` as the public type, while keeping the existing TX `Channel` TX-only and leaving `RxDevice` as the internal backend / compatibility layer."
Follow-up tracker #2397 (Introduce `fl/channels/rx` with `RxChannel` as the public RX API) is CLOSED. The codebase reflects this:
src/fl/channels/rx/exists (channel.cpp.hpp,channel.h,config.h,types.h,_build.cpp.hpp), and the commits that delivered it are merged:b22324b3eb— Add public RxChannel API under fl/channels/rxb42e28c3f0— Move RX interface under fl/channelsc269a6a024— refactor(fl/channels): relocate id_tracker and RxDevice impl into channels APINothing further to do on this design-discussion issue.
🤖 Reviewed with Claude Code