Fix for enable/disable FFT task.

This commit is contained in:
Blaz Kristan 2022-07-06 19:46:32 +02:00
parent 96e04f1c54
commit 377a11b160

View File

@ -1026,17 +1026,22 @@ class AudioReactive : public Usermod {
#ifdef WLED_DEBUG #ifdef WLED_DEBUG
fftTime = sampleTime = 0; fftTime = sampleTime = 0;
#endif #endif
if (init) vTaskDelete(FFT_Task); // update is about to begin, remove task to prevent crash if (init && FFT_Task) {
else { // update has failed or create task requested vTaskSuspend(FFT_Task); // update is about to begin, disable task to prevent crash
// Define the FFT Task and lock it to core 0 } else {
xTaskCreatePinnedToCore( // update has failed or create task requested
FFTcode, // Function to implement the task if (FFT_Task)
"FFT", // Name of the task vTaskResume(FFT_Task);
5000, // Stack size in words else
NULL, // Task input parameter xTaskCreatePinnedToCore(
1, // Priority of the task FFTcode, // Function to implement the task
&FFT_Task, // Task handle "FFT", // Name of the task
0); // Core where the task should run 5000, // Stack size in words
NULL, // Task input parameter
1, // Priority of the task
&FFT_Task, // Task handle
0 // Core where the task should run
);
} }
} }