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

    M5 Paper : Unable to clear screen contents

    Scheduled Pinned Locked Moved Arduino
    3 Posts 2 Posters 3.9k 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.
    • Z Offline
      zitrone
      last edited by

      Hi folks,

      I just started using M5 paper and went through the documentation at
      https://docs.m5stack.com/en/api/m5paper/epd_canvas

      Using this info, I created a canvas with some content in the setup.
      Then, in the loop I wish to clear the canvas and display some other content.
      The code is as follows :

      #include <M5EPD.h>
      M5EPD_Canvas canvas(&M5.EPD);
      void setup() {
      M5.begin(); //Init M5Paper.
      M5.EPD.SetRotation(90); //Set the rotation of the display.
      M5.EPD.Clear(true); //Clear the screen.
      M5.RTC.begin(); //Init the RTC.

      canvas.createCanvas(540, 960); //Create a canvas.
      canvas.setTextSize(3); //Set the text size.
      canvas.drawString("Hello World", 10, 10); //Draw a string.
      canvas.pushCanvas(0,0,UPDATE_MODE_DU4); //Update the screen.
      delay(2000);
      }

      void loop() {
      M5.EPD.Clear(true); //Clear the screen.
      canvas.drawString("Another string", 10, 60); //Draw a string.
      canvas.pushCanvas(0,0,UPDATE_MODE_DU4); //Update the screen.
      delay(5000);
      }

      Expected : I see only 'Another string' after refresh every 5 seconds.
      Actual : Both 'Hello World' and 'Another string' are displayed.
      :(

      I think I am missing something. May you please explain what is going wrong here?

      Thanks,
      Zitrone

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

        Hello @zitrone

        the reason both strings are displayed is that both strings are present in the canvas which then is pushed to the screen. M5.EPD.Clear(true); only clears what is on the screen but it leaves the canvas untouched, therefore the next pushCanvas() displays both strings again on the screen.

        Try adding a canvas.fillCanvas(0); after the M5.EPD.Clear(true); - this will clean the canvas (and remove the first string). See also the touch example.

        BTW: you don't need the M5.EPD.Clear(true); in the loop for one string to be removed and the other to be added. (Note: w/o there might be a slight shadow where the first string was.)

        Thanks
        Felix

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

        1 Reply Last reply Reply Quote 1
        • Z Offline
          zitrone
          last edited by

          @felmue Thank you for the quick reply.
          Yes, it works perfectly. :)

          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