TFT_eSPI how; blank out long line remnants

I am printing lines of text to my LCD display. Some long, some short.
How can I perform a "clear to end of line" function?

Previous line Outside Humidity = 57% RH
Current line Pressure = 1007 F
Current line Pressure = 1007 F= 57% RH < this is what ends up being displayed

Options I can think of are:

  1. add spaces to the end of each line text
  2. Over write each line with spaces before writing the target line
  3. write a filled rectangle before writing the target line.

Padding doesn't seem to work without the use of datums.

Am I missing a better option? Should padding work without datums?

Thanks
John

Maybe output the previously printed data in the background colour before printing the new value ?

1 Like

Thank you, I'll try that. I did however reread the padding function and my statement about datums seems to be in error.

I'll investigate more.

Thanks

Overprinting the previous value does, of course, involve knowing it but I hope that your code does that already so that values are only printed when they change

Print to a line buffer the width of the screen. Before printing to that line/buffer, blank out the buffer.
EDIT: OOPS, you had that as option 2.

1 Like

Thanks for the reply :slight_smile:

Bebbington once posted re-printing the old text using the background color for the text color, then print the new data in the appropriate color. That may be the fastest 'erase'.

Using the following format for setTextColor() may make these processes unnecessary.

However, if the string to be overwritten becomes shorter, the characters before the overwrite will remain, so you will need to use a formatted string or add spaces to the end.

Although it is not a perfect example, please refer to the following example:

Curious way to refer to me!

Yes, I did and that is still my preferred option. I'm not the originator of the idea though, I read it somewhere, here I imagine, but I don't have a clue where or who from.