How to overwrite text to the Arduino ILI9341 display

The Adafruit_ILI9341 library cannot print new text over other text correctly. The old text is not erased first as it should. With this library extension we can overwrite text and numbers correctly.
Download the library and examples at GitHub: ILI9341-overwrite-text
Download the Adafruit_ILI9341 library HERE.
With printing strings, the old text that has to be overwritten must be entered in the 2nd argument:

tft.printNew("New text", "Old text");

 With printing numbers, the number of digits (3) must be specified in the 2nd argument:

tft.printNew(i, 3);

With printing floats, the number of digits (3) must be specified in the 3nd argument. Use constrain to limit the number of digits:

float kPa = ???; // calculate kPa
float kPaTFT = constrain(kPa, 0, 100); // max 3 numbers
tft.printNew(kPaTFT, 1, 3); // print float 1 digit, max 3 numbers

Note that the background color and the cursor position are managed automatically.

Other libraries for the ILI9341 TFT

PaulStoffregen/ILI9341_t3 Only works with the Teensy
Bodmer/TFT_ILI9341 The pins DC CS RST cannot be passed via the constructor

Passing the pin numbers for DC, CS and RST

In this example, analog pin A0 is used for RST.

const byte TFT_DC = 3;
const byte TFT_CS = 1;
const byte TFT_RST = A0;

Adafruit_ILI9341_Albert tft = Adafruit_ILI9341_Albert(TFT_CS, TFT_DC, TFT_RST);

Alternate printing of different fonts and text sizes

The order of instructions to the ILI9341 display is important, otherwise the text will not be aligned properly:

tft.setFont(f); // do FOR setCursor
tft.setCursor(x, y); // do AFTER setFont
tft.setTextColor(c, bg); 




Do you have any comments about the website? Please let me know.