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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login