Fist time user here. I have come up with some code to increase or decrease a number on the screen with a button press. It works but I was wondering if there is a better way to do this than black out the old number before printing the new one on top of it. The only similar examples I have been able to find would, with each button press, erase and redraw the entire screen.
Is there a better way to redraw the number?
Here is the section of code from within the loop.
// determine if a button has been pressed
if ((XX >= 10 && YY >=85) && (XX <= 50 && YY < 115))
{
tft.setCursor(10,25);
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.println(ch1);
delay(100);
ch1 = ch1 + 5;
if (ch1 >= 255)
{ ch1 = 255; }
tft.setCursor(10,25);
tft.setTextColor(WHITE);
tft.println(ch1);
}
if ((XX >= 10 && YY >=180) && (XX <= 50 && YY < 210))
{
tft.setCursor(10,25);
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.println(ch1);
delay(100);
ch1 = ch1 - 5;
if (ch1 <= 0)
{ ch1 = 0; }
tft.setCursor(10,25);
tft.setTextColor(WHITE);
tft.println(ch1);;
}