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

    FAQS
    4
    5
    17.1k
    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
      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
        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
          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
            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
              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
              • First post
                Last post