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

    How to avoid text flicker ?

    Scheduled Pinned Locked Moved FAQS
    5 Posts 4 Posters 19.6k Views 3 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.
    • D Offline
      DrWino
      last edited by

      I am writing text to the same location with updated values. I get the text superimposed on the old text. i use a space, the reset the setCursor, then write the new text. But I get flicker - How to avoid this ? Also if you make a filled rectangle and then write text on it - the whole thing flickers like mad.

      1 Reply Last reply Reply Quote 0
      • S Offline
        Sergey_Urusov
        last edited by

        Just save previous displayed value in global variable, before display compare with saved, and display only if they differs.

        1 Reply Last reply Reply Quote 1
        • reaper7R Offline
          reaper7
          last edited by

          this is a good option as @Sergey_Urusov wrote,
          instead rectangle you can also overwrite old value with inverted color
          something like this:

          #include <M5Stack.h>
          
          void setup() {
          
            M5.begin();
          
            M5.Lcd.fillScreen(BLACK);
            M5.Lcd.setTextSize(7);
          
          }
          
          void loop(){
            static int rndold = -1;
          
            int rnd = random(0, 100);
          
            if (rnd != rndold) {
              //overwrite old value with inverted color
              M5.Lcd.setCursor(40, 40);
              M5.Lcd.setTextColor(BLACK);
              M5.Lcd.printf("%02d", rndold);
              //write new value
              M5.Lcd.setCursor(40, 40);
              M5.Lcd.setTextColor(WHITE);
              M5.Lcd.printf("%02d", rnd);
              rndold = rnd;
              delay(250);
            }
            
          }
          

          MY GITHUB: https://github.com/reaper7/

          1 Reply Last reply Reply Quote 0
          • dasloloD Offline
            daslolo
            last edited by

            You can try PrintToSprite in the TFT_eSPI library. https://github.com/Bodmer/TFT_eSPI/issues/116

            1 Reply Last reply Reply Quote 0
            • dasloloD Offline
              daslolo
              last edited by

              Here is the solution. https://github.com/Bodmer/TFT_eSPI/tree/master/examples/Sprite/Sprite_scroll

              Thanks to @Calin

              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