Last active
April 16, 2020 10:22
-
-
Save hpwit/48b27cf38223e7309b84c87a6ee54d47 to your computer and use it in GitHub Desktop.
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
#include "FastLED.h" | |
FASTLED_USING_NAMESPACE | |
#define FASTLED_SHOW_CORE 0 | |
static TaskHandle_t FastLEDshowTaskHandle2 = 0; | |
static TaskHandle_t userTaskHandle = 0; | |
void FastLEDshowESP322() | |
{ | |
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(FastLEDshowTaskHandle2); | |
//to thge contrary to the other one we do not wait for the display task to come back | |
} | |
} | |
void FastLEDshowTask2(void *pvParameters) | |
{ | |
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 500 ); | |
// -- Run forever... | |
for(;;) { | |
// -- Wait for the trigger | |
ulTaskNotifyTake(pdTRUE,portMAX_DELAY); | |
FastLED.show(); | |
userTaskHandle=0; //so we can't have two display tasks at the same time | |
} | |
} | |
void setup() { | |
xTaskCreatePinnedToCore(FastLEDshowTask2, "FastLEDshowTask2", 1000, NULL,3, &FastLEDshowTaskHandle2, FASTLED_SHOW_CORE); | |
} | |
void loop() | |
{ | |
//now call this instead of FastLED.show() | |
FastLEDshowESP322(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment