I am new to arduino but not new to programming, even though I did it long time ago. :*
I am playing with a LCD TFT module and I want to show some variables on the display ( like: "Time: 10:30:24") and have the data update.
I used to use the \r control character to have the cursor come back to the beginning of the same line and rewrite the same line with the new variable, something like that:
But it does not work, the cursor does not come back, it just ignores the \r: Time: 6:12:46Time: 6:12:48Time: 6:12:50Time: 6:12:53Time: 6:12:55Time: 6:12:57
Any thoughts?
P.S.: I'm using the following Adafruit libraries:
Adafruit_GFX.h
Adafruit_HX8340B.h
usgine2003:
I am playing with a LCD TFT module and I want to show some variables on the display ( like: "Time: 10:30:24") and have the data update.
Which TFT? Which library?
It doesn't surprise me that \r isn't supported. Use the cursor function (or whatever it is called in this undisclosed library) to move the cursor back.
I used the display.setCursor(0,0) to make the cursor come back, and it works, but the numbers are overwritten, and it shows a mess where the numbers change, because it draws new pixels without clearing the previous ones... :0
I can clear the whole screen and refresh it, but the only function I found is * display.fillScreen(BLACK);* and it takes too long...
PaulS:
Just as a sanity check, change the last line to:
display.print("Time:xxxxxxxxxxxxxxxxxx"); // bunch of spc to clear the line
What happens?
What do you expect println() to do? I would NOT be using println() to put data on an LCD of any sort.
Does not work, it writes "xxxxxxxxxxxxxx" on top of the other characters.
println() appends a NEWLINE at the end, and this won't work, since I want the same line to be updated with the new time:
Time: 12:34:25 --> and the numbers change on the same line.
Does not work, it writes "xxxxxxxxxxxxxx" on top of the other characters.
As opposed to? Erasing the existing characters?
YES
println() appends a NEWLINE at the end, and this won't work
So, why are you using it?
[/quote]
It does not matter on the last line, before printing the blanks, i have a setCursor(0,0) that brings the cursor back to the beginning of the SAME line.
display.println(GPS.milliseconds);
[b]display.setCursor(0,0);[/b]
display.print("Time: "); // bunch of spc to clear the line
void Adafruit_GFX::setTextColor(uint16_t c) {
textcolor = c;
textbgcolor = c;
// for 'transparent' background, we'll set the bg
// to the same as fg instead of using a flag
}
I've looked into both libraries Adafruit_GFX and Adafruit_HX8340B and I can't see anything related to a function named "print", how is it possible that display.print or println can be used? Is there a magic trick? I would like to understand.
guix:
I've looked into both libraries Adafruit_GFX and Adafruit_HX8340B and I can't see anything related to a function named "print", how is it possible that display.print or println can be used? Is there a magic trick? I would like to understand.