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

    Arduino M5Core2 Buttons

    Arduino
    1
    2
    543
    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.
    • S
      SirMichael
      last edited by

      I'm having trouble understanding how to use the M5Stack Core2, creating new buttons for my project.

      I can use the 3 buttons (A, B & C) and for some screens, I need two more buttons, with similar properties.

      I've been studying the Example: events_buttons_gestures_rotation.ino but I can't make heads or tails of it. I've added print statements to see which subroutines are executed and I don't understand what the "doRotation()" or what the swipe gestures do.

      The only thing that I've discovered in playing with it is that if I press one of the buttons twice quickly that the "toggleColor" is executed.

      The few comments are useless to me.

      Is there a simpler example somewhere that I can use to create a few buttons when I need them for the "wasReleased()" and "wasPressedFor()" functions?

      Sir Michael

      S 1 Reply Last reply Reply Quote 0
      • S
        SirMichael @SirMichael
        last edited by kuriko

        @SirMichael

        I found what I was looking for, a simple sketch to create a button. I did some minor massages, taking from the events_buttons_gestures_rotation.ino and figured it out.

        #include <M5Core2.h>
        
        ButtonColors on_clrs = { RED, WHITE, WHITE };
        ButtonColors off_clrs = { BLACK, WHITE, WHITE };
        Button myButton(10, 10, 80, 60, false, "Button", off_clrs, on_clrs, TL_DATUM );
        
        void setup() {
          M5.begin();
          M5.Buttons.draw();
        }
        
        void loop() {  
          M5.update();
          if (myButton.wasReleased()) Serial.print("* ");
          
        }
        

        Sir Michael

        1 Reply Last reply Reply Quote 1
        • First post
          Last post