Cleanly displaying changing numbers (or text) on a LCD

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Tormad
 
Posts: 8
Joined: Tue Jul 12, 2022 1:23 pm

Cleanly displaying changing numbers (or text) on a LCD

Post by Tormad »

I have the 2.8” TFT LCD and I’ve got it connected to a QT PY. I would like to display a number on the display – from a temperature sensor but when the number changes and is displayed on the LCD it writes over the top of the number that was there previously and it ends up being a giant mess (you can see both numbers, one on top of the other).
The only way I’ve figured out how to get around this is to fill the screen with a solid colour to cover over the previous number and then printing the new number. This results in the number being “clean” but there is a visible “flash” when the LCD first fills the screen with the solid colour and then prints the number on top of that. Is there a better way of doing this?

Also, I'm using the Arduino IDE.

User avatar
adafruit2
 
Posts: 22111
Joined: Fri Mar 11, 2005 7:36 pm

Re: Cleanly displaying changing numbers (or text) on a LCD

Post by adafruit2 »

hi, you can use the text Setcolor procedure to set the foreground and background. If you set the background as a color, it'll overwrite the previous text.

User avatar
Tormad
 
Posts: 8
Joined: Tue Jul 12, 2022 1:23 pm

Re: Cleanly displaying changing numbers (or text) on a LCD

Post by Tormad »

Thank you for your reply! I didn't know about this so I read up on it and it looks like that method doesn't work with custom fonts which is my case. It looks like with custom fonts you need to draw a filled rectangle and then write the text but I tried that and it unfortunately causes the text to flash briefly when it changes.

User avatar
alphanumeric
 
Posts: 633
Joined: Sun Sep 07, 2014 7:06 pm

Re: Cleanly displaying changing numbers (or text) on a LCD

Post by alphanumeric »

I'm doing similar things on SPI displays on Pi's and PICO's, in Python and Micro Python.
I clear the buffer, or fill it with black, color (0, 0, 0). Rewrite it with the new info and then display it. I refresh the whole screen.

User avatar
adafruit2
 
Posts: 22111
Joined: Fri Mar 11, 2005 7:36 pm

Re: Cleanly displaying changing numbers (or text) on a LCD

Post by adafruit2 »

FYI, circuit python, has a system called displayio, which handles all of this for you cleanly

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”