Skip to content

honor WAIT_TIME - #1

Merged
samguyer merged 1 commit into
samguyer:masterfrom
h3ndrik:patch-1
Jan 23, 2018
Merged

samguyer merged 1 commit into
samguyer:masterfrom
h3ndrik:patch-1

Conversation

@h3ndrik

@h3ndrik h3ndrik commented Jan 23, 2018

Copy link
Copy Markdown

for chipsets that need it (for example TM1829)

makes my TM1829 stop flickering.

for chipsets that need it (for example TM1829)
@h3ndrik

h3ndrik commented Jan 23, 2018

Copy link
Copy Markdown
Author

update: still observed some flickering. further testing required. but implementing the WAIT_TIME is probably nice anyways.

@samguyer

Copy link
Copy Markdown
Owner

@h3ndrik I have observed flickering myself as well, so I'm glad to see something that helps. I'm still puzzled about why the flickering happens, though.

@samguyer
samguyer merged commit d0f0efa into samguyer:master Jan 23, 2018
@samguyer

samguyer commented Jan 23, 2018 •

Copy link
Copy Markdown
Owner

@h3ndrik You might want to try running FastLED.show() on the other core. I wrote a post about how to do it (see below). I'd be interested to find out if that eliminates the flickering....

--

The ESP32 support for Arduino maps both the user code and the WiFi support to core 1. I'm not sure why, but that's how it is set up. One thing you can do is set up a separate task to do the FastLED.show() on the other core (core 0). I worked out the code and tested it on the FastLED "Demo reel".

Add the following code anywhere in your sketch:

// -- The core to run FastLED.show()
#define FASTLED_SHOW_CORE 0

// -- Task handles for use in the notifications
static TaskHandle_t FastLEDshowTaskHandle = 0;
static TaskHandle_t userTaskHandle = 0;

void FastLEDshowESP32()
{
    if (userTaskHandle == 0) {
        const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 200 );
        // -- Store the handle of the current task, so that the show task can
        //    notify it when it's done
        userTaskHandle = xTaskGetCurrentTaskHandle();

        // -- Trigger the show task
        xTaskNotifyGive(FastLEDshowTaskHandle);

        // -- Wait to be notified that it's done
        ulTaskNotifyTake(pdTRUE, xMaxBlockTime);
        userTaskHandle = 0;
    }
}

void FastLEDshowTask(void *pvParameters)
{
    // -- Run forever...
    for(;;) {
        // -- Wait for the trigger
        ulTaskNotifyTake(pdTRUE, portMAX_DELAY);

        // -- Do the show (synchronously)
        FastLED.show();

        // -- Notify the calling task
        xTaskNotifyGive(userTaskHandle);
    }
}

Then add code to initialize the task in your setup() function:

    // -- Create the FastLED show task
    xTaskCreatePinnedToCore(FastLEDshowTask, "FastLEDshowTask", 2048, NULL, 2, &FastLEDshowTaskHandle, FASTLED_SHOW_CORE);

Finally, call the new show function in place of regular show:

  // send the 'leds' array out to the actual LED strip
  FastLEDshowESP32();
  // FastLED.show();

samguyer pushed a commit that referenced this pull request Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants