Skip to content

Instantly share code, notes, and snippets.

@hpwit
Last active May 30, 2018
Embed
What would you like to do?
FastLed.show on the second core esp32
#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
noInterrupts();
userTaskHandle = xTaskGetCurrentTaskHandle();
// -- Trigger the show task
xTaskNotifyGive(FastLEDshowTaskHandle);
// -- Wait to be notified that it's done
ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS( 100 ));
interrupts();
userTaskHandle = 0;
}
}
void FastLEDshowTask(void *pvParameters)
{
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 500 );
// -- Run forever...
for(;;) {
// -- Wait for the trigger
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
// -- Do the show (synchronously)
FastLED.show();
// -- Notify the calling task
xTaskNotifyGive(userTaskHandle);
}
}
void setup() {
xTaskCreatePinnedToCore(FastLEDshowTask, "FastLEDshowTask", 10000, NULL,2, &FastLEDshowTaskHandle, FASTLED_SHOW_CORE);
...
and nbow call FastLEDshowESP32(); instaead of FastLED.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment