Hi to all,
I have created a new project stitching codes from here and there. I don’t know if it’s messy but it seems to run pretty well. I ended up with an overwriting problem. I can bypass it by drawing a black rectangle on the screen, but like this, I go back to flickering problems. The “ILI9341_BLACK” part of the command tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK) seems that it doesn’t work. I put the specific code here but I attach the whole code for better review as well as an image of the screen. Any solution will be appreciated. Thank you.
What’s dive’s type?
If it’s > 1000 you are Printing a float with 1 decimal and if not you are printing just that variable. So the display format might vary
Erasing some text could be done by printing in reverse color the same value at the same exact location
The usual way of solving the problem is indeed to overwrite the previous value before printing the new one.
To avoid flickering as far as possible only write to the screen when a value changes, only erase that value, write any fixed text only once in the program, if possible only set the font size and text colour once in the program, do not erase and write the whole screen again, if a value changes by a small amount (particularly a float) do not print it until it changes by a significant amount
If you have done all that then you have probably done as much as you can
What’s dive’s type?
If it’s > 1000 you are Printing a float with 1 decimal and if not you are printing just that variable. So the display format might vary
Erasing some text could be done by printing in reverse color the same value at the same exact location
J-M-L:
So have you tried printing the former value at the very same position but in black over a black background before painting the new value?
yes, I did. And it's not good. If the result has one digit, is ok. If the result has two digits, also ok. But from two digits back to one digit, there comes the problem.
But from two digits back to one digit, there comes the problem.
That’s probably not the way you do it. You memorize the OLD value somewhere. When it comes to changing the value (ie the NEW value is different than the OLD one), then you first write again the OLD one in black to clean up and then you write the NEW one in white, and you store NEW in OLD for next time.
void displayTemparature(int t)
{
static int oldTemp = -1000; // start with something impossible
if (oldTemp != -1000) { // we have something to erase
tft.setCursor(55, 187);
tft.setTextColor(ILI9341_BLACK, ILI9341_BLACK); // black on black to erase
tft.print(oldTemp);// erase old temperature
}
if (t != oldTemp) { // no display needed otherwise, save time, no blink
tft.setCursor(55, 187);
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK); // white on black to display
tft.print(t); // display new temperature
oldTemp = t; // memorize it for erasing later
}
}
J-M-L:
That’s not the way you do it. You memorize the OLD value somewhere. When it comes to changing the value (ie the NEW value is different than the OLD one), then you first write again the OLD one in black to clean up and then you write the NEW one in white, and you store NEW in OLD for next time.
sorry, I should have uploaded my last test code. When everything is under 8, it's fine. When it comes over it, everything is ok also. But when it goes from values more than 8 to under 8, here is the problem (from 2 digits to one digit, or from 3 to 2). Apparently, the 2nd part "ILI9341_BLACK" of the command "tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK)" which would have solved the problem, doesn't work either.
Why is the different cursor positioning based on the new value of dive before writing diveold in black ? Surely the positioning should depend on the value of diveold
UKHeliBob:
Why is the different cursor positioning based on the new value of dive before writing diveold in black ? Surely the positioning should depend on the value of diveold