ESP32 WS2812 LEDs (An alternative approach)

For general Flowcode discussion that does not belong in the other sections.
Post Reply
mnfisher
Valued Contributor
Posts: 984
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 105 times
Been thanked: 516 times

Flowcode v10 ESP32 WS2812 LEDs (An alternative approach)

Post 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 10 times

Martin

Post Reply