Skip to content

Instantly share code, notes, and snippets.

@hpwit
Last active May 10, 2018 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hpwit/3fa60a760af536a7ee861be3e925bfed to your computer and use it in GitHub Desktop.
Save hpwit/3fa60a760af536a7ee861be3e925bfed to your computer and use it in GitHub Desktop.
exampleFastledcore0
#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