🤖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.

    M5 Stick/StickC
    3
    4
    7.8k
    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
      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
        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
          m5stack
          last edited by

          you can through create a thread to solve it.

          1 Reply Last reply Reply Quote 0
          • K
            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
            • First post
              Last post