Register / Login  |  Desktop view  |  Jump to bottom of page

tcMenu Arduinio library » Widget change current state outside of main loop

Author: k
27/09/2021 11:32:15
Hello, I am using the widget function (like the wireless connection on some of the examples, esp8266 etc...)

The functionality works. But when I want to change the widget state inside of a function, it only changes once the function ends and effectively goes to another iteration of the loop.

What I want to do:
Is call an external function to do something (like wifimanager). This causes the menu to stop, until the function ends.
I want to change the widget in the title to reflect (like a save icon on video game save areas).
I want to set the icon at the beginning of the function, then change it again at the end of the function. But doing this doesn't do anything until the function ends which defeats the purpose.

is there any way to update the widgets outside of the main loop? I tried
taskManager.runLoop();
inside the external function but to no avail.

any help is appreciated

Author: davetcc
27/09/2021 13:16:30
TaskManagerIO requires that all the functions that you call are either asynchronous or can frequently call taskManager.yieldForMicros(..) if they need to be long-running or block for any reason. Tasks (including everything that tcMenu does) need the run loop to constantly run. I recommend that you read through the TaskManagerIO documentation: https://github.com/davetcc/TaskManagerIO.

On ESP32 or mbed, if you cannot arrange for this then you could create an additional thread to do the long running task, as long as the library in question is thread-safe enough to support that.

To be honest, most Arduino libraries don't block and in most cases just integrate with the loop pattern easily.




Register / Login  |  Desktop view  |  Jump to top of page