TFT SPI ILI9441 leaves unwated numbers on screen

Hi there, I am using a TFT SPI 2.8 display with the Adafruit GFX and ILI9341 libraries
to print a float with a gas sensor reading using 2 decimals (tft.print(sensorvalue,2). Printing up ppms is ok, but when the sensing value goes back down to zero it leaves numbers sometimes with three or four decimals, usually on the places that has printed a number before. The serial monitor prints 2 decimals up and down fine. I have tried converting to string, characters , etc but to no avail. It seems to be a display issue not a C++ problem. I tried clearing the screen but the blinking is bothersome and it is not a real fix. Is there any command on these libraries that might help clearing some tipe of tft memory? Thank you
3

Post your code.

You probably need to clear part of the display where the number are with something like
https://wiki.microduinoinc.com/Tft.fillRect()

Have a look at this post also...

@ivanyepez777
Make sure you have it only refreshing the data if and when the data actually changes or you will still get the blinking problem. Sort of like this:

if (now.month() != prevMonth)
  {
    prevMonth = now.month();
    tft.fillRect(59, 3, 33, 21, BLACK);
    tft.setCursor(59, 3);
    if (now.month() < 10) {
      tft.print("0");
    }
    tft.print(now.month());
  }

Please post your code.

Yes. Or you can write the old number in the same color as the background, then write the new, changed number.

This may make less flicker or other objectionable artifacts.

Try both see if one is better different.

a7

Without the code you have worked on you have to guess what needs to be modified. Please, Isolate the lines that cause the problem and share them, so it will be easier to comment.

HI thank you for the suggestions but I cannot solve the problem. Here is part of the code.

int sensorCO2= A3 ;
Y=(float)analogRead(sensorCO2);
CO2level=log(Y);
CO2ppm=pow(10,CO2level);
tft.print(CO2ppm,2);
serial.print(CO2ppm);

As sensor is exposed to gas the printout is always with 2 decimals in both the TFT and the serial monitor.
When the sensor is not exposed to gas anymore, the gas concentration reading starts to come down and this is what happens:

CO2ppm (TFT) CO2ppm(Serial Monitor)
XXX.XX XXX.XX
XX.XXX XX.XX
X.XXXX X.XX

So the TFT does not mantain the two decimals, it is as if it remembers the digits it used (5 in my example) and as it comes down it keeps on printing 5 numbers. It will stay like that until reset. The serial monitor maintains its two decimals so that is why I think the problema is in the TFT.

image

It does not appear that you made any attempt to apply the solutions offered.

Please post code where you have tried the suggestions and describe why they are not successfully fixing you problem.

a7

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.