How to avoid text flicker ?
-
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.
-
Just save previous displayed value in global variable, before display compare with saved, and display only if they differs.
-
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); } } -
You can try PrintToSprite in the TFT_eSPI library. https://github.com/Bodmer/TFT_eSPI/issues/116
-
Here is the solution. https://github.com/Bodmer/TFT_eSPI/tree/master/examples/Sprite/Sprite_scroll
Thanks to @Calin
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