Not overwriting the character on 2.2 SPI TFT

I am using QVGA 2.2 TFT SPI 240x320 (ILI9341) with four keys (say UP, DOWN, OK & EXIT).

I want to up and down the particular digit in number using UP & DOWN key. (Starting from unit digit, I am shifting to tenth digit using OK key).

But I have found that the particular digit is over writing and the current and previous digits are merging with each other.

I want that the current digit is overwrite on previous digit.

Have anybody work on that?? Please suggest for that.

Which library are you using?

If it is an Adafruit_GFX style library, you use setTextColor(foreground, background) instead of setTextColor(foreground)

Note that this only applies to the default system font. If you use the Free fonts, you must draw the background yourself.

David.

Hi David,

I am using ILI9341 library.
As per information, for text size 1, 5x8 pixel will be use and it will be multiply by size.
If it is not so, then how many pixels it will take in different text size.
I am using tft.fillRect (x,y,width,height,background color) to overwrite the digit on particular pixel position.

I am not aware of any library called ILI9341. Please post a link.

All the same, your fillRect() method looks like an Adafruit_GFX style method.
The system font is 5x7 which means you allow a 6x8 box to give a space between adjacent characters.

If you use setTextSize(2) you will need a 12x16 box.
Since the system font is monospaced, it is easy to calculate positions, lengths etc.

The Free fonts are proportional. You have to calculate the size and postion of any previous character before you know what to rub out. Very complicated when you want to overwrite i with w.

Many proportional fonts have different width letters but specify digits with equal width. It makes invoices easier to read.

David.

Try with this libraries: ILI9341_due and Utouch

Work it well with UNO, MEGA or Due

Load this example: UNO_CD4050BE_ILI9341_due_Control

Here all libraries that you need

The key: sprintf

The simplest solution appears to be to use David's suggestion of specifying a background colour for the text, viz:

setTextColor(foreground, background);

If the text is scaled then the Adafruit library will aoutmatically scale the backgorund area drawn unless you are changing the size of the drawn text from a large to a smaller size as the numbers are changing.