Seeedstudio TFT V2 flickering

Folks,

for my cnc control i’m building a hand-held unit with a tft display to show the 5 axis values and F,S. So total 7 different values.

I’m facing the problem that when I update the values the text is flickering. this brings me to the basic question: how to update text on such a screen?

i see 2 different possibilities:

1: fill a rectangle with the background color where the old text is and then write it again with the new value.
but then I paint more pixel then necessary

2: i write the old value again with the background color and write the new value with the text color

I tried both but the flickering is not acceptable.

what can I do?

Thanks, Duesentieb

my code:

#include <stdint.h>
#include <TFTv2.h>
#include <SPI.h>

const int textDistance = 30;

const int pinS = 15;
const int pinF = 14;

char x[6];
char y[6];
char z[6];
char a[6];
char b[6];
char s[6];
char f[6];

void setup() {

Serial.begin(9600);
pinMode(pinS, INPUT);
pinMode(pinF, INPUT);

TFT_BL_ON;
Tft.TFTinit();
Tft.setDisplayDirect(DOWN2UP);
Tft.drawString(“X:”, 10 + 0 * textDistance, 310, 3, WHITE);
Tft.drawString(“Y:”, 10 + 1 * textDistance, 310, 3, WHITE);
Tft.drawString(“Z:”, 10 + 2 * textDistance, 310, 3, WHITE);
Tft.drawString(“A:”, 10 + 3 * textDistance, 310, 3, WHITE);
Tft.drawString(“B:”, 10 + 4 * textDistance, 310, 3, WHITE);
Tft.drawString(“F:”, 10 + 5 * textDistance, 310, 3, WHITE);
Tft.drawString(“S:”, 10 + 6 * textDistance, 310, 3, WHITE);

}

void loop() {

Tft.drawString(x, 10 + 0 * textDistance, 240, 3, BLACK);
Tft.drawString(y, 10 + 1 * textDistance, 240, 3, BLACK);
Tft.drawString(z, 10 + 2 * textDistance, 240, 3, BLACK);
Tft.drawString(a, 10 + 3 * textDistance, 240, 3, BLACK);
Tft.drawString(b, 10 + 4 * textDistance, 240, 3, BLACK);
Tft.drawString(s, 10 + 5 * textDistance, 240, 3, BLACK);
Tft.drawString(f, 10 + 6 * textDistance, 240, 3, BLACK);

String(analogRead(pinS)).toCharArray(x, 6);
String(analogRead(pinS)).toCharArray(y, 6);
String(analogRead(pinS)).toCharArray(z, 6);
String(analogRead(pinS)).toCharArray(a, 6);
String(analogRead(pinS)).toCharArray(b, 6);
String(analogRead(pinS)).toCharArray(s, 6);
String(analogRead(pinF)).toCharArray(f, 6);

/* ouput to serial, disabled for debugging
Serial.print(“x:\t”);
Serial.print(x);
Serial.print("\ty:\t");
Serial.print(y);
Serial.print("\ty:\t");
Serial.print(z);
Serial.print("\tz:\t");
Serial.print(a);
Serial.print("\ta:\t");
Serial.print(b);
Serial.print("\tb:\t");
Serial.print(s);
Serial.print("\ts:\t");
Serial.print(f);
Serial.println(f);
*/

Tft.drawString(x, 10 + 0 * textDistance, 240, 3, WHITE);
Tft.drawString(y, 10 + 1 * textDistance, 240, 3, WHITE);
Tft.drawString(z, 10 + 2 * textDistance, 240, 3, WHITE);
Tft.drawString(a, 10 + 3 * textDistance, 240, 3, WHITE);
Tft.drawString(b, 10 + 4 * textDistance, 240, 3, WHITE);
Tft.drawString(s, 10 + 5 * textDistance, 240, 3, WHITE);
Tft.drawString(f, 10 + 6 * textDistance, 240, 3, WHITE);

delay(500);
}