I have been reading quite a lot on FreeRTOS fundamentals the last couple of days.
Also build a first plugin to learn how RTOS could aid in running timing critical plugin tasks.
Timing critical in this context means a very smooth and consistent response to events or schedules.
(for things like high frequency pulse detection, ISR's would still be required)
Running a fast blinking LED without any interference from other tasks is fun to see at work:
Code: Select all
void P254_blinkLED( void * parameter ) {
TickType_t xLastWakeTime;
const TickType_t xFrequency = 50;
xLastWakeTime = xTaskGetTickCount();
boolean state = 0;
pinMode(P254_LED, OUTPUT);
while (true) {
state = (!state);
digitalWrite(P254_LED, state);
vTaskDelayUntil( &xLastWakeTime, xFrequency );
}
}
To avoid that running other features will interfere with normal ESPEasy operation, the menu and it's launch actions will run from another RTOS task.
As I'm not planning to reinvent the wheel, work will be based on this library:https://github.com/tomsuch/M5StackSAM
The entire ESPEasy project was never build with being "ThreadSafe" in mind. And it looks not so "Easy" to make it so.
But RTOS could really add some value to specific plugins without to much work and risk if you take special care about addressing (updating) global datastructures and running global functions. The LCD menu will currently only run functions private to it's plugin so that should be safe...