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

    paper s3 micropython example for Power.lightSleep()

    Scheduled Pinned Locked Moved PRODUCTS
    7 Posts 2 Posters 648 Views
    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.
    • J Offline
      jhfoo2
      last edited by

      Tried using uiflow to do lightsleep but it just hangs and needs a power restart. Does anyone have a working sample?

      felmueF 1 Reply Last reply Reply Quote 0
      • felmueF Offline
        felmue @jhfoo2
        last edited by felmue

        Hello @jhfoo2

        please have a look at the UIFlow2 Project Zone example I created: M5PaperS3_Light_Sleep_Test_UIFlow2.4.3

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        J 1 Reply Last reply Reply Quote 0
        • J Offline
          jhfoo2 @felmue
          last edited by

          @felmue said in paper s3 micropython example for Power.lightSleep():

          M5PaperS3_Light_Sleep_Test_UIFlow2.4.3

          Thanks! I see that was able to sleep and loop, and I can add simple code to detect where it was touched that woke it up.

          Can you help me understand why you put in the 1sec time.sleep()?

          1 Reply Last reply Reply Quote 0
          • J Offline
            jhfoo2
            last edited by jhfoo2

            Also: I try to skip uiflow and code directly in micropython. Do you know why I can't get touched X,Y in this code:

                while True:
                  StatusLabel.setText('SLEEP')
                  time.sleep(1)
                  print ('sleep')
                  Power.lightSleep(10 * 1000000, True)
                  StatusLabel.setText('WAKE')
                  time.sleep(1)
                  print ('wake')
                  time.sleep(1)
                  M5.update()
                  time.sleep(1)
                  (TouchX, TouchY, _, _) = M5.Touch.getTouchPointRaw()
                  print (f'{TouchX}, {TouchY}')
            
            
            felmueF 1 Reply Last reply Reply Quote 0
            • felmueF Offline
              felmue @jhfoo2
              last edited by felmue

              Hi @jhfoo2

              well, in my case, without the 1 second delay the UI label wasn't fully updated on the display. Or in other words, ESP32 already went into light sleep while in the background the display was still finishing to update. (In your case it might be ok without the delay as the print() takes some time.)

              Edit:
              I think the reason for not getting the touched X, Y is that internally the wake-up code already read the touch IC registers and by doing so cleared the values. But I could be wrong about that as it is simply a guess.

              I updated my example M5PaperS3_Light_Sleep_Test_UIFlow2.4.3 in the UIFlow2 Project Zone to read touch coordinates after wake-up from touch. It's a bit tricky as M5.update() needs to be called repeatedly until the number of touch points drops back to 0.

              Thanks
              Felix

              GPIO translation table M5Stack / M5Core2
              Information about various M5Stack products.
              Code examples

              J 1 Reply Last reply Reply Quote 0
              • J Offline
                jhfoo2 @felmue
                last edited by

                @felmue thanks that works! But I don't get if the while loop in readAndClearTouch() is necessary? It will be 0 in the 2nd iteration and should exit.

                felmueF 1 Reply Last reply Reply Quote 0
                • felmueF Offline
                  felmue @jhfoo2
                  last edited by

                  Hello @jhfoo2

                  well, in my experience and with my M5PaperS3 it takes a couple of readouts (e.g. M5.update()) until the return value from the touch controller goes back to 0.

                  Please let me know if you find a more elegant solution.

                  Thanks
                  Felix

                  GPIO translation table M5Stack / M5Core2
                  Information about various M5Stack products.
                  Code examples

                  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