I have a countdown timer on a LCD touch screen. It shows a status message (string) and a number (int).
When the length of the string or int changes the old value stays. For example:
100
99
actually looks like
100
990
Because I didn't clear the pixels from the 0 at the end of 100 so it's still there.
I want to avoid clearing the screen every time because it'll make the screen flash a lot. I'd rather clear it selectively when the length changes, so when it goes from 3 digits to 2 (100 to 99) then clear. When the status message changes (one every 30-150 cycles) then clear the screen.
How would I copy the variable status_msg.name or status_msg.count and then compare it to itself next time through the loop to look for a change. Probably a simple question but I'm brain farting on how to do it.
pylon, I tried your code and it didn't fix it, the output was exactly the same.
For the graphic display I'm using UTFT.
I'm connecting a pair of 2560s to ROS (Robot Operating System) and am using a custom library that is generated based on message definitions defined in ROS. status_msg.name and .count are from that library.
For the string should I just concatenate a space on the end?
status_msg_name2 = status_msg.name + " ";
The trouble with printing a space is that I don't know where to print it. The space isn't needed in a fixed location, it'll change depending on the length of the string/int being printed.
I'm changing it on the ROS side to just use strings and put extra spaces in it. Seems like that's easier than trying to do it on the Arduino. Thanks for the help everyone.