How to detect button press with blocking call.
-
While using BLE features the scanning for services method uses a blocking call. During that time a button press is not caught using M5.BtnA.wasPressed(). However the button press needs to be recorded and handled after returning from the blocking call.
Is that possible and how? I am using Arduino in Visual Studio IDE.
Any suggestions are welcome. -
It sounds like you may need to set the button to be used as an interrupt, take a look at this guide and see if it helps https://lastminuteengineers.com/handling-esp32-gpio-interrupts-tutorial/ this discussion may also have some related info to help https://github.com/m5stack/M5Stack/issues/52
-
you can through create a thread to solve it.
-
Thanks lukasmaximus and m5stack. Combining the two answers solved my problem. Split the work over two cores and added a suggested delay between calling M5.BtnA.wasPressed() and it seems to work as hoped for. Did not use the interrupt solution though interesting.