Counting Down without flicker ILI9431, can it be done?

Hi all, I am working on building a small Dash for interfacing with an aftermarket ECU.

I want to display engine parameters such as RPM, AFR coolant temp etc.

I have tested an arduino UNO, and a Teensy 3.2 with a couple of 320x280 ILI9431 type displays, I have

tried Several libraries ( ADAFRUIT_ILI9431, ADAFRUIT_ILI9431_AS, TFT_ILI9431, ILI8431_t3 and others....)

and have gotten great results from both, aside from one

nagging issue. If I use the command "tft.setTextColor(TFT_RED, TFT_BLACK);" (Adafruit library)

then instigate a counter that counts up from, say, 0-6000 and back down again, when counting up the

numbers on the display are perfect, fast and no flicker.

However, when counting down from 6000-0, Depending on the font or particular library, parts of, or whole

numbers are left on the end of the text line. Generally it is a whole or partial "0", such that when going

from 1000 to 999 the display will show 9990. depending on the font, sometimes this happens when

changing from a 2 to a 1, part of the 2 remains behind.

I have tried several nasty hacks to avoid this; drawing small filled boxes of re-drawing the text in the back

ground color ( leads to terrible flickering ) drawing small filled boxes or redrawing the text based on specific

number changes ( i.e. going from 1000 to 999, redraw the value in the back ground color ), this works kind

of ok, but still has flickering issues and requires a ton of "if" statements.

I'm wondering if there isn't something simple im missing, or if some guru has a simple elegant solution?

Ive also tried converting the int to a string and printing spaces and nothing i do seems to work, just seems

odd that i can count up with excellent results, but counting down is a nightmare...

Thanks

Go on. The ILI9341 works just fine. I have not heard of ILI9431.

You have already discovered how to do "transparent" printing with setColor(foreground)
And "rubout" printing with setColor(foreground, background)

Think about it. 1234 takes 4 digits. 123 takes only 3 digits. If you want a pleasant looking display, you pad it with leading zeros or spaces. Then you will see a steady number.

The Arduino Print.h methods do not have any way to do this rather obvious "formatting". But it is not difficult to do it yourself e.g. with a helper function.

If you are too idle to add the leading spaces or zeros, you can just print the number with a trailing space. This will rubout the extra digit when you go from 1000 to 999.

David.

Wait... do you clear the display before printing?
I've got no experience with tft displays... but any other display I've worked with showed the same behavior whenever I forgot to clear/reset/reinitialize it before printing