Last active
May 10, 2018 12:58
-
-
Save hpwit/3fa60a760af536a7ee861be3e925bfed to your computer and use it in GitHub Desktop.
exampleFastledcore0
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 | |
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( 500 ));//portMAX_DELAY); | |
//delay(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); | |
FastLED.show(); | |
xTaskNotifyGive(userTaskHandle); | |
} | |
} | |
void setup() { | |
xTaskCreatePinnedToCore(FastLEDshowTask, "FastLEDshowTask", 1000, NULL,2, &FastLEDshowTaskHandle, FASTLED_SHOW_CORE); | |
//your code | |
} | |
void loop() | |
{ | |
FastLEDshowESP32(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment