ESP32 FastLED show() shift

Hello :slight_smile:,

I'm using FastLED on ESP32 to control 4 LEDs strips, 1 task running 1 strip.
After a while I get data shift on a single or multiple strip.
For exemple I ask LED 4 on strip 1 to turn on, nothing happen. When I ask an other LED on any strip to turn on, LED 4 on strip 1 turn on but not the asked LED, and so on.
It happens randomly and I'm sure to set the right LED with the right color (I put a print on it).
What could it be ?
Thank you for any help.

Here a smaller version of the code :slight_smile:

#include "StripBox.h"

#include <Arduino.h>
#include <FastLED.h>

CRGB StripBox::s_Strips[4][NUM_LEDS];

StripBox::StripBox(uint8_t stripNum)
{
    m_StripNum = stripNum;

    queueStrip = xQueueCreate(MAX_STRIP_QUEUE_LENGHT, sizeof(int[STRIP_MSG_LENGTH]));

    switch (stripNum)
    {
    case 0:
        FastLED.addLeds<NEOPIXEL, STIP_0_PIN>(s_Strips[0], NUM_LEDS);
        break;
    case 1:
        FastLED.addLeds<NEOPIXEL, STIP_1_PIN>(s_Strips[1], NUM_LEDS);
        break;
    case 2:
        FastLED.addLeds<NEOPIXEL, STIP_2_PIN>(s_Strips[2], NUM_LEDS);
        break;
    case 3:
        FastLED.addLeds<NEOPIXEL, STIP_3_PIN>(s_Strips[3], NUM_LEDS);
        break;
    default:
        Serial.println("[StripBox::StripBox] Strip index out of bounds");
        break;
    }
}

void StripBox::startLoop()
{
    xTaskCreatePinnedToCore(
        this->s_LoopCall,
        "LED",
        1480,
        (void *)this,
        1,
        &taskHandle,
        1);
}

void StripBox::s_LoopCall(void *_this)
{
    StripBox c = *((StripBox *)_this);
    c.loop();
}

void StripBox::controlLEDProcess(int data[STRIP_MSG_LENGTH])
{
    CRGB color = CRGB(data[3], data[4], data[5]);
    controlLED(data[2], color);
}

void StripBox::controlLED(uint8_t ledIndex, CRGB color)
{
    s_Strips[m_StripNum][ledIndex] = color;
}

void StripBox::addToDataQueue(int data[STRIP_MSG_LENGTH])
{
    xQueueSend(queueStrip, data, 1000);
}

void StripBox::loop()
{
    for (;;)
    {
        std::fill_n(m_Data, STRIP_MSG_LENGTH, INT_MAX);

        xQueueReceive(queueStrip, &m_Data, queueDelay);

        controlLEDProcess(m_Data);

        vTaskDelay(1 / portTICK_PERIOD_MS);
        FastLED.show();
        vTaskDelay(delay / portTICK_PERIOD_MS);
    }
}

Don't post snippets (Snippets R Us!)

what about the .h and the main code?

can't do much with that

There was another discussion regarding the ESP-implementation of FastLED. A solution wasn't found.

I have used the Adafruit neopixel library and haven't run into any ESP anomalies.

You do ofcourse have a level shifter between the 3.3volt-logic of the ESP and 5volt-logic of the LEDs.
Without that you can't be sure if the problem is in the code.
Leo..

Thank you for your help. I'm sorry but I can't put all the code.
I'll try the Neopixel solution. I don't thinks it's related to the 5V (I have level shifter).
I'll let you know if it work.

Hello,

It seems that I was not using the latest version of FastLED. I updated and it seems to be fixed. It is well marked that the update greatly improves compatibility with the ESP32.
Which seems to be true.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.