For example, I have a task that periodically monitors the mechnical button on my device. If the button is pressed, I want to activate OTA.
I create a task to monitor button:
Code: Select all
xTaskCreatePinnedToCore(
Task_read_encoder
, "Task_read_button" // A name just for humans
, 4096 // This stack size can be checked & adjusted by reading the Stack Highwater
, NULL
, 2 // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
, NULL
, ARDUINO_RUNNING_CORE);
and my read button task is as following:
Code: Select all
void Task_read_button(void *pvParameters) // This is a task.
{
(void) pvParameters;
for (;;)
{
// read the input on analog pin A3:
if(read_button_debounce() == 1)
{
Serial.print("Button click has been detected");
START_OTA();
}
vTaskDelay(5); // one tick delay (15ms) in between reads for stability
}
}