I am new to using the esp32 and am trying to figure out how to make a "Abort" button on my esp32 webpage abort a for loop in a higher priority task (task pulses in code below). The problem is that when the for loop in the Pulse Code below is running, the webserver is blocked and I cannot interrupt the for loop.
Any idea on how to implement an abort on the webpage.
Main code:
Code: Select all
...
server = start_webserver();
xTaskCreate(&pulses, "pulses", 2048, NULL, 2, NULL);
...
Code: Select all
...
httpd_uri_t root = {... .handler = root_get_handler ...};
httpd_register_uri_handler(server, &root);
esp_err_t root_get_handler(httpd_req_t *req)
{
if (httpd_query_key_value(buf, "run", param, sizeof(param)) == ESP_OK) {
xQueueSend(pulsequeue, &steps, 1000 / portTICK_PERIOD_MS) ;
}
if (httpd_query_key_value(buf, "abort", param, sizeof(param)) == ESP_OK) {
NEED HELP HERE;
}
}
Code: Select all
void pulses(void *pvParameters)
{
...
if (xQueueReceive(pulsequeue, &r, 1000 / portTICK_PERIOD_MS))
{
for (uint a = 0; a < abs(r) * 1000; a++){
gpio_set_level(pin1, 0)
vTaskDelay(delay / portTICK_PERIOD_MS);
gpio_set_level(pin1, 1);
vTaskDelay(delay / portTICK_PERIOD_MS);
// I NEED A WAY TO INTERRUPT THIS FOR LOOP WHEN USER PRESSES ABORT ON WEBPAGE
}
}
}
Thank you.
Progit