ESP32 and LED WS2811 (WS2812)

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
stefan.erni
Valued Contributor
Posts: 1009
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 192 times
Been thanked: 217 times

ESP32 and LED WS2811 (WS2812)

Post by stefan.erni »

Hi to All

The LED is working nice and it's comfotable to use.
There is a little problem in a program with WS2812
I have made a test with WS2812

1.This LED can only be initialized in the main, it is not possible in the macro.
The LED maybe give some problems with the power management and maybe also with xtask

2.The LED is in the 3D Panel and it's always open the 3D panel, is there a way to config FC10 not to open the 3D Panel or move the LED to 2D Panel?
Attachments
Test_ws28111.fcfx
(19.24 KiB) Downloaded 5 times

mnfisher
Valued Contributor
Posts: 1474
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 708 times

Re: ESP32 and LED WS2811 (WS2812)

Post by mnfisher »

I attached 1 ws2812 - and can confirm that there us an issue...

Move WS2812::Initialise to a macro and it stops working - which is very odd. Not at all sure why it wouldn't work from a macro (as main is just a macro too!)

Also - the minimum number of LEDs seems to be 2?

I have done some code in the past using LEDs in a task (just as a demo) - I'll see if I can rummage it out.

Will fiddle a little more tomorrow.

mnfisher
Valued Contributor
Posts: 1474
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 708 times

Re: ESP32 and LED WS2811 (WS2812)

Post by mnfisher »

Attached is my demo of a LED 'handler' running in a task...

I used the 'new' RMT handler from the espressif framework - and it's all hidden in supplementary code...

The macro (runs here as a task) 'Rainbow' which creates an LED 'strip' - and then displays a few colours (from an array) briefly before running a rainbow scroller 500 times (and repeat).

Main - just outputs a time (using a timer interrupt to increase) every second - just to prove it's alive.

It's a little bit rough - pin for the LED strip and number of LEDs is defined in supplementary code - the properties should do a #define

Code: Select all

#define RMT_LED_STRIP_GPIO_NUM      14

#define EXAMPLE_LED_NUMBERS         1
#define EXAMPLE_CHASE_SPEED_MS      10
Set to suit (here running one LED on pin 14)

display - takes an array of bytes (3 per LED) and outputs them to the LED strip. Here - I actually output 24 LEDs values (and at present it doesn't check for a correlation between this and number of LEDs defined) (As you can guess the initial demo used 24 LEDs :-) )

As you are using two LEDs - you could define a 6 byte array - and pass this - not time before work today. The macro SetAllLEDs demonstrates how the colours are set in the array (a SetLED(n, r,g,b) can be modelled on this.

Removing the 'rainbow' code would simplify things a bit.

Martin
Attachments
sk6812.fcfx
(27.48 KiB) Downloaded 6 times

Post Reply