I am using a 1351 OLED and have a page switch routine that on button push moves to a new page.
In the fuel and water pages, as the numbers update from the sensor I am trying to find a function that will just clear the screen area that doesnt change.
For instance if the sensor shows 103 and then 50 I dont want the 3 (of the 103 ) to still display.
If I just fill the screen black at the start of each page it has the effect of making everything disappear and then rewrite and I only want the unused area to clear.
void changeDisplay()
{
dispChngpinState = digitalRead(dispChngpin);
// Serial.println (buttonPushCounter);
if (dispChngpinState != lastdispChngState)
{
if (dispChngpinState == LOW)
{
buttonPushCounter++;
delay(100);
}
}
lastdispChngState = dispChngpinState;
if (buttonPushCounter == 1)
{
RTCNow();
}
if (buttonPushCounter == 2)
{
tft.fillScreen(BLACK);
buttonPushCounter = 3;
}
if (buttonPushCounter == 3)
{
tft.setCursor(30, 5);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.println("Suzuki");
tft.setCursor(55, 40);
tft.setTextSize(4);
tft.println("7");
}
if (buttonPushCounter == 4)
{
watertemp();
tft.setCursor(30, 5);
tft.setTextColor(WHITE, BLACK);
tft.setTextSize(2);
tft.println("Temp");
tft.setTextSize(4);
tft.setCursor(30, 30 );
tft.setTextColor(WHITE, BLACK); // refreshes text area
tft.println(temperature,2);
}
if (buttonPushCounter == 5)
{
fuelSender();
tft.setCursor(30, 5 );
tft.setTextColor(WHITE, BLACK);
tft.setTextSize(2);
tft.println("Fuel");
tft.setTextSize(4);
tft.setCursor(30, 30 );
tft.setTextColor(WHITE, BLACK); // refreshes text area
tft.println(itoa(fuel, buf5, 10));
tft.fillScreen(BLACK);
}
if (buttonPushCounter == 6)
{
tft.fillScreen(BLACK);
buttonPushCounter = 1;
}
}