Last active
October 15, 2023 20:18
-
-
Save hpwit/d29333138c7952d254ad90844802ee55 to your computer and use it in GitHub Desktop.
FastLed.show on the second core esp32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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