For those who missed this like me,

For those who missed this like me, @Paul_Stoffregen wrote a DMA version of NeoPixel driving on Teensy chips. I’m assuming the Teensy Serial port is more capable than some other platforms where this is probably not possible (or maybe it is on some other platforms too? I already checked that the 16bit arduinos can only do serial up to 230400, so it’s not fast enough).
https://www.pjrc.com/non-blocking-ws2812-led-library/

@Paul_Stoffregen , is that a driver you can offer to @Daniel_Garcia and @Mark_Kriegsman as in help integrate in FastLED if you have a chance? I was always surprised that Teensy was not as well supported in that regard than ESP32, but I guess with OctoWS2811 there was less of a need.
That said, this DMA driver is timely because I had just realized that Teensy did not support driving SmartMatrix + FastLED WS2812B, but now it can, even a bit of extra integration in FastLED would be awesome.
By the way, ESP8266 also has a DMA driver (single channel) that abuses the I2S output: https://github.com/JoDaNl/esp8266_ws2812_i2s/ (not in FastLED though, but usable out of tree if you don’t need the FastLED APIs).

Thanks to @Louis_Beaudoin for the pointer.

By the way @Paul_Stoffregen you wrote on your page “Normally with FastLED or Adafruit NeoPixel, only 3 bytes of memory are used per LED. WS2812Serial requires 15 bytes, the normal 3 for drawing, and 12 for composing the serial data.”.
Just to be clear, you’re talking about 15 bytes of memory per pixel that needs to be pushed. So if your strip is 4096 LEDs, you need 60KB of RAM to hold that data instead of just 12KB. Is that correct?
It’s not ideal, but realistically, people are unlikely to drive much more than 256 or 512 LEDs on a serial output, meaning 7.5KB which is not terrible.
If you have 1024 LEDs or more, you should be using parallel output anyway, and this DMA driver won’t work (in that case go back to OctoWS2811 or ESP32 which can also do up to 8 line parallel output natively if you want DMA and 24 if bit banging is good enough).

FastLED has a “driver” which uses this library, so you can have non-blocking, no-interrupts WS2812 output and all of FastLED’s awesome features. In fact, 1 of the 2 examples that comes with the WS2812Serial library shows how to use it. In Arduino, just click File > Examples > WS2812Serial and open the one that says FastLED in the name! :slight_smile:

Yes, on the memory, 15 bytes per pixel is correct. That’s the trade-off, much more than the normal 6 bytes for double buffered. Those 15 bytes and consuming one serial port gives you output that is all DMA-based, never blocks or delays any interrupts (not even for 1 clock cycle) and doesn’t ever use any interrupt (so works even if something else shut off all interrupts). Of course it’s fully double buffered, so compare to 6 bytes. You get some pretty awesome features - and on Teensy 3.5 or 3.6 where the chip has 256K of RAM, or even Teensy 3.2 with 64K, there’s usually plenty of RAM available.

@PaulStoffregen Thank you. Sure enough, it’s been in FastLED a long time, I never even saw it:
https://github.com/FastLED/FastLED/blob/master/platforms/arm/k20/ws2812serial_controller.h
As for ping that you shouldn’t use it with 4K LEDs, I agree, that’s also what I wrote in my last message (i.e. you want parallel output for more than 512 LEDs IMO).
As for double buffering, I never quite considered the issue of asynchronous updates that can indeed push a frame while you’re in the middle of writing to your FB. Thanks for pointing that out. The solution I use on ESP32 does suffer from that issue I guess.