Page 1 of 1

ESP32 WS2812 LEDs (An alternative approach)

Posted: Sat Apr 27, 2024 9:07 pm
by mnfisher
This is some alternative code for WS2812 LEDs running on the esp32.

Rather than the RMT based component (I get issues with this being deprecated...)

I tried two alternatives - using the i2s hardware where I got 'reasonable' results. LEDs would set but occasional glitches ( I think the T1L time I got was a little short).

And this which uses the SPI and DMA. The code is actually very short - there are some structures defined in supplementary code (where the maximum number of LEDs is given a maximum and the IO pin is hardcoded as GPIO_25)

It would convert fairly easily to a component - with a user selected pin and number of LEDs - and there are two fairly short macros that do the work (Refresh and Initialise). For conversion to a component - the header would need a #define for the pin and _1 _2 etc for the structures.

It this sample - I bolted on some Rainbow code - which rather clumsily creates a colour then unpacks it again. It's also hardcoded to 24 WS2812 LEDs (which is what I had to hand)
SPI_LEDs.fcfx
(17.86 KiB) Downloaded 489 times

Martin