Skip to content

Adding more than 3 controllers breaks FastLED on an ESP32 using PlatformIO #722

Closed

Description

@outlandnish

Using the Arduino framework for the ESP32 in PlatformIO , I have issues running code with more than 3 controllers. I'm using this with an ESP-WROOM32. It works fine for 3 controllers but the moment I add a fourth or fifth (see the ledTest function) it does not render the LEDs at all.

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

const int STATUS_COUNT = 1;
const int STATUS_PIN = 21;
const int STRIP_COUNT = 45;
const int STRIP_ONE_PIN = 16;
const int STRIP_TWO_PIN = 17;
const int STRIP_THREE_PIN = 18;
const int STRIP_FOUR_PIN = 19;
TaskHandle_t ledTask;

void printInfo();

// led test methods
void ledTest(void *parameter);
void showGradient(CRGB *strip, uint8_t hue, int count);
void color(CRGB *strip, int count, CRGB color);
std::vector<CRGB*> strips;

void setup() {
    Serial.begin(115200);
    printInfo();

    xTaskCreate(ledTest, "ledTest", 5000, NULL, 1, &ledTask);
}

void loop() {
    delay(10);
}

void printInfo() {
    Serial.print("ESP SDK Version: ");
    Serial.println(ESP.getSdkVersion());

    Serial.print("ESP Chip Revision: ");
    Serial.println(ESP.getChipRevision());
}

void ledTest(void *parameter) {
    Serial.println("Starting LED test");
    strips.push_back(new CRGB[STATUS_COUNT]);
    strips.push_back(new CRGB[STRIP_COUNT]);
    strips.push_back(new CRGB[STRIP_COUNT]);
    strips.push_back(new CRGB[STRIP_COUNT]);
    strips.push_back(new CRGB[STRIP_COUNT]);

    FastLED.addLeds<WS2812B, STATUS_PIN, GRB>(strips[0], STATUS_COUNT);
    FastLED.addLeds<WS2812B, STRIP_ONE_PIN, GRB>(strips[1], STRIP_COUNT);
    FastLED.addLeds<WS2812B, STRIP_TWO_PIN, GRB>(strips[2], STRIP_COUNT);
    FastLED.addLeds<WS2812B, STRIP_THREE_PIN, GRB>(strips[3], STRIP_COUNT);
    FastLED.addLeds<WS2812B, STRIP_FOUR_PIN, GRB>(strips[4], STRIP_COUNT);

    int count;
    uint8_t hue = 0;
    for (;;) {
        hue = (hue + 1) % 255;
        for (int i = 0; i < strips.size(); i++) {
            count = i == 0 ? STATUS_COUNT : STRIP_COUNT;
            showGradient(strips[i], hue, count);
        }
        FastLED.show();
        delay(10);
    }
    vTaskDelete(NULL);
}

void showGradient(CRGB *strip, uint8_t hue, int count) {
    fill_rainbow(strip, count, hue);
}

void color(CRGB *strip, int count, CRGB color) {
    for (int i = 0; i != count; i++)
        (*strip)[i] = color;
}

Activity

  1. focalintent commented on Jan 20, 2019

    @focalintent
    Contributor

    So - the code you have doesn't even compile - or at least it doesn't compile in the Arduino IDE (even if I fix the typo in your fill_rainbow line to fill_rainbow(strips, count, hue); - as there's no cast from std::vector<CRGB*> to CRGB* being found.

    Can you try making this work under the Arduino IDE - if the 5 strips still isn't working there, I'll have @samguyer take a look at it - but platform IO isn't an officially tested/supported build environment. I don't have any multi-strip esp32 setups here right now, and won't be able to spin one up for a bit, otherwise I'd test it here.

    (Mostly I want to make sure that this is also an issue in the build environment that Sam is likely to be using before I send him off chasing)

  2. outlandnish commented on Jan 21, 2019

    @outlandnish
    Author

    @focalintent sorry I had changed the code I had copied over in the sake of brevity and missed some things. I've gone ahead and fixed it.

    When you comment out the last two FastLED.addLED lines, the strips iterate through the rainbow. Else, it freezes after setting that first status strip to red.

  3. focalintent commented on Jan 21, 2019

    @focalintent
    Contributor

    Does it still not work for you will you build/install it through the Arduino IDE?

  4. focalintent commented on Jan 21, 2019

    @focalintent
    Contributor

    Also does it work when you have the code in loop vs creating a task?

  5. outlandnish commented on Jan 21, 2019

    @outlandnish
    Author

    @focalintent I've tried both. It doesn't work through the Arduino IDE and it doesn't work if I move the code to loop() instead of in a separate FreeRTOS task.

  6. outlandnish commented on Jan 21, 2019

    @outlandnish
    Author

    @focalintent for reference, I've used the SmartLeds library here and it works for all five strips using RMT.

  7. focalintent commented on Jan 21, 2019

    @focalintent
    Contributor

    Thanks - I’m trying to narrow the test case for @samguyer to look at.

  8. samguyer commented on Jan 21, 2019

    @samguyer
    Contributor

    Hi! I'll give this code a test myself and let you know what I find. The RMT driver has been used by a number of people to drive a bunch of strips, though, so maybe there's something else going on.

  9. focalintent commented on Jan 21, 2019

    @focalintent
    Contributor

    Also, @samguyer - pull the most recent build of the library - a) to see if there's any outstanding changes between what you have in your branch and what I have here and b) I went through and annotated the methods called from the interrupt handler with IRAM_ATTR

  10. outlandnish commented on Jan 31, 2019

    @outlandnish
    Author

    @samguyer any luck reproducing this issue?

  11. outlandnish commented on Jun 10, 2019

    @outlandnish
    Author

    Closing this because it seems to be fixed in 3.2.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions