Just tried to get a neo-pixel ring working using the ws2812 component (v5.1) - and compilation fails. My code 'above' now produces wrong timings as well and nothing works
I came up with this using the new 'RMT' interface from one of the example files - in Rainbow I demonstrate drawing a FC defined pixel buffer and also using the example 'rainbow' (which was my initial 'demo')
I needed a quick demo of a task in FC - so main is outputting timings to UART whilst Rainbow looks after the LEDs autonomously (here - displays red, green, blue, white, rainbow - and repeat)
Compilation - you need to add LED_strip_encoder.c and .h to project/main and point the include in supplementary code to the .h file (it's hard-coded here - so you'll need to change it to suit - there should be a way to set the include directory- INCLUDE_DIRS is maybe a clue

) (Note these files are from C:\espressif\frameworks\esp-idf-v5.1.1\examples\peripherals\rmt\led_strip\main - depending on your esp directory)
Code: Select all
#include "driver/rmt_tx.h"
#include "R:\sk6812_(1)\main\led_strip_encoder.h" // Change this to suit your directory names!
#define RMT_LED_STRIP_RESOLUTION_HZ 10000000 // 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
#define RMT_LED_STRIP_GPIO_NUM 21 // This could be passed as an argument to 'create'
#define EXAMPLE_LED_NUMBERS 24 // Number of LEDs in 'string' change to argument?
Also add led_strip_encoder.c to CMakeLists.txt (in project/main) which should end with the line
Code: Select all
idf_component_register(SRCS "esp-project.c" "led_strip_encoder.c"
INCLUDE_DIRS "")
It was a quick-and-dirty hack so the pin used is in supplementary code - as is number of LEDs (pin 21 and 24 here) - display will take any number (and count is number of bytes not LEDs) The LEDs I have seem to take GRB data? - and timings are in led_strip_encoder.c (ws2812 here)
The naming is a bit 'odd' - I called the initialisation code create_rainbow, the draw 'rainbow' rainbow and output an array 'display'
Random file naming going on - sorry...
To create the directories - attempt to compile the .fcfx file (which will fail) then extract the zip file to project_name/main (and I'm assuming you'll change sk6812 (1) to something more memorable)
Martin