You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been battling to figure out how to clear the previous printed text, I have searched everywhere and I am sure there is a simple answer.
It doesn't matter whether I use tft.drawString() or tft.println(), if the previous string printed was longer than the new, the remainder of the previous string remains on the screen.
Using the code below as an example, if x is set to a multiple digit value and then set back to zero the remainder multiple digits remain.
For example: x was 0, then was set to 9999 and then set back to 0, the screen would show "x: 0999" instead of "x:0".
UPDATE: I have managed to get the following working use tft.setTextPadding() and tft.drawString() but how would you achieve this with tft.println() as adding padding did not seem to work for me?
tft.setCursor(0, 0);
tft.println("x: " + String(x)); // previous string x
tft.println("y: " + String(y)); // previous string y
tft.println("z: " + String(z)); // previous string z
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setCursor(0, 0);
tft.println("x: " + String(x)); // new string x
tft.println("y: " + String(y)); // new string y
tft.println("z: " + String(z)); // new string z
}`
On Wed, 16 Oct 2024 at 18:20, Basitadam ***@***.***> wrote:
`void loop()
{
tft.setTextColor(TFT_WHITE, TFT_WHITE);
int16_t padSize = tft.textWidth("x: 9999");
tft.setCursor(0, 0);
tft.println("x: " + String(x)); // previous string x
tft.println("y: " + String(y)); // previous string y
tft.println("z: " + String(z)); // previous string z
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setCursor(0, 0);
tft.println("x: " + String(x)); // new string x
tft.println("y: " + String(y)); // new string y
tft.println("z: " + String(z)); // new string z
}`
I know. It is a dirty trick
—
Reply to this email directly, view it on GitHub
<#3506 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABL4XIXHKH3U4Q2BT2QUJYLZ32N7XAVCNFSM6AAAAABP3LBOWWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJXGQ2TEMJWGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
Hi,
I have been battling to figure out how to clear the previous printed text, I have searched everywhere and I am sure there is a simple answer.
It doesn't matter whether I use tft.drawString() or tft.println(), if the previous string printed was longer than the new, the remainder of the previous string remains on the screen.
Using the code below as an example, if x is set to a multiple digit value and then set back to zero the remainder multiple digits remain.
For example: x was 0, then was set to 9999 and then set back to 0, the screen would show "x: 0999" instead of "x:0".
UPDATE: I have managed to get the following working use tft.setTextPadding() and tft.drawString() but how would you achieve this with tft.println() as adding padding did not seem to work for me?
This is working
This is not, is there a way?
Thank you
The text was updated successfully, but these errors were encountered: