🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    How to detect button press with blocking call.

    Scheduled Pinned Locked Moved M5 Stick/StickC
    4 Posts 3 Posters 9.1k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      Kees
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • lukasmaximusL Offline
        lukasmaximus
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • m5stackM Online
          m5stack
          last edited by

          you can through create a thread to solve it.

          1 Reply Last reply Reply Quote 0
          • K Offline
            Kees
            last edited by

            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.

            1 Reply Last reply Reply Quote 0

            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
            • First post
              Last post