Last active
May 11, 2018 17:41
-
-
Save hpwit/57776e504fdc65bf809e6793159c4047 to your computer and use it in GitHub Desktop.
FastLed on second core but with handing back the hand to the main loop
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 | |
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); | |
memcpy(leds,artnet.getframe(),123*48*sizeof(CRGB)); | |
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); | |
//and now call FastLEDshowESP322(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment