Repository navigation
Description
Summary
After more design work, the right public shape for RX appears to be:
- keep the existing
fl::ChannelTX/output-oriented - add a sibling RX API under
src/fl/channels/rx/** - make the public RX object
fl::RxChannel - keep
RxDeviceas the internal backend layer / compatibility shim
This is different from folding RX into the current Channel class, and different from leaving RX as only a backend-oriented RxDevice factory.
The key constraint is that every device needs a channel-shaped public handle, because that is what enables AutoResearch and validation flows to reason in terms of persistent, addressable channels.
Why this shape
Today the codebase has a mismatch:
- TX is channel-managed and channel-addressable:
src/fl/channels/channel.hsrc/fl/channels/data.hsrc/fl/channels/driver.hsrc/fl/channels/manager.h
- RX is backend/device-oriented:
src/fl/rx_device.hsrc/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.hsrc/platforms/esp/32/drivers/gpio_isr_rx/gpio_isr_rx.h
And AutoResearch already treats RX conceptually as a channel:
examples/AutoResearch/AutoResearch.inoexamples/AutoResearch/AutoResearchTest.hexamples/AutoResearch/AutoResearchTest.cppsrc/fl/channels/detail/validation/rx_test.h
But the public API still exposes RX mostly as a backend/device abstraction.
That creates the wrong center of gravity.
Recommendation
Introduce a sibling RX subsystem:
src/fl/channels/rx/types.hsrc/fl/channels/rx/config.hsrc/fl/channels/rx/channel.hsrc/fl/channels/rx/manager.h(lightweight, optional but likely useful)
Public type:
fl::RxChannel
Internal/backend types remain:
RxDeviceRmtRxChannelGpioIsrRxFlexPwmRxChannelNativeRxDevice
Proposed public API
Types
namespace fl {
enum class RxBackend : u8 {
PLATFORM_DEFAULT,
RMT,
ISR,
FLEXPWM
};
struct RxChannelConfig {
fl::string name;
int pin = -1;
RxBackend backend = RxBackend::PLATFORM_DEFAULT;
fl::string affinity; // optional exact backend name override
size_t edge_capacity = 4096;
fl::optional<u32> hz = 40000000;
u32 signal_range_min_ns = 100;
u32 signal_range_max_ns = 100000;
u32 skip_signals = 0;
bool start_low = true;
bool io_loop_back = false;
bool use_dma = false;
};
}Channel object
namespace fl {
class RxChannel {
public:
static fl::shared_ptr<RxChannel> create(const RxChannelConfig&);
int id() const;
const fl::string& name() const;
int getPin() const;
fl::string getEngineName() const;
bool begin(const RxChannelConfig&) FL_NOEXCEPT;
bool finished() const FL_NOEXCEPT;
RxWaitResult wait(u32 timeout_ms) FL_NOEXCEPT;
fl::result<u32, DecodeError> decode(const ChipsetTiming4Phase&, fl::span<u8>) FL_NOEXCEPT;
size_t getRawEdgeTimes(fl::span<EdgeTime> out, size_t offset = 0) FL_NOEXCEPT;
bool injectEdges(fl::span<const EdgeTime>) FL_NOEXCEPT;
};
}FastLED entrypoint
auto rx = FastLED.addRx(rx_config);This mirrors FastLED.add(...) on the TX side and gives AutoResearch a first-class RX channel object.
Important non-goals
Not this
- do not make RX inherit the existing TX
Channel - do not force RX into
IChannelDriver::enqueue()/show()/poll() - do not keep
RxDeviceas the long-term primary public abstraction
Why not
The current TX Channel is tightly coupled to CPixelLEDController and TX submission semantics. RX has a different lifecycle:
begin()wait()decode()getRawEdgeTimes()
So RX should be a sibling channel type, not a subclass of the TX channel.
AutoResearch impact
This shape is specifically intended to make AutoResearch cleaner.
AutoResearch should be able to think in:
- TX side:
Channel - RX side:
RxChannel - orchestration:
fl::validation
That means updating AutoResearchConfig from shared_ptr<RxDevice> to shared_ptr<RxChannel> and moving the canonical capture logic out of example-local helpers into src/fl/channels/validation/*.
Migration path
- Add
fl/channels/rx/*. - Implement
RxChannelas a wrapper over existingRxDevicebackends. - Add
FastLED.addRx(...). - Migrate AutoResearch and validation code to
RxChannel. - Keep
fl/rx_device.has a compatibility shim for a while.
Possible transition pattern:
RxDevice::create<T>()forwards internally toRxChannel::create(...)- existing platform code stays mostly in place initially
Optional lightweight manager
A lightweight fl/channels/rx/manager.h may still be useful for:
- lookup by id / name / pin
- registration / discovery for AutoResearch
- keeping RX channel-addressable
This should be much lighter than ChannelManager and should not copy TX driver semantics blindly.
Tradeoffs
Pros
- satisfies the requirement that every device has a channel
- keeps RX addressable by id / name / pin
- preserves existing TX
Channelsemantics - gives RX a clean public home next to the channels subsystem
- keeps backend/resource refactors possible under the API later
Cons
fl/channels/**becomes explicitly broader than TX-only, which needs docs clarityRxChannelis channel-like but not API-identical toChannel- some validation-specific decode policy will still live in validation helpers, not in generic backend code
Related
- FastLED Channels API #2167
- ESP32-S3: I2S driver starves websockets, SPI output incorrect, Audio driver FPS impact #2254
- Refactor RX devices into a shared signal-device layer; keep Channel API TX-only #2396
Bottom line
The cleanest next step is:
Add fl/channels/rx with RxChannel as a first-class public API, and demote RxDevice to backend/compatibility status.
Activity