Page 1 of 1

Print new number on screen and removing previous characters

Posted: Thu Dec 23, 2021 4:14 pm
by Xbiotec
hi,
On ESP32 TTGO like below to print number or text, the the printing start at de defined position X and Y. (start to print from left)
when print a number, it could be good to justify it a right and clear the previous characters. May be there is way ?

I tried these 2 ways but not good and difficult to manage well the offset and can not remove the previous first digit!

1- do not use offset , the problem is that numbers are printed from left to right and previous last digit still on display
screen 2.jpg
screen 2.jpg (23.14 KiB) Viewed 4451 times
2- Print of 9999 in green at X and Y position then print 999 in orange at X+offset and Y position. Previous fist digit "9" in green is still on the display too
screen 1.jpg
screen 1.jpg (20.48 KiB) Viewed 4451 times

Do you have a way to solve that? ( cleardisplay is not nice)
thx for your prompt reply

Re: Print new number on screen and removing previous characters

Posted: Thu Dec 23, 2021 4:48 pm
by LeighM
Add a space character to the text string.
You might need to do that based on the string length.

Re: Print new number on screen and removing previous characters

Posted: Thu Dec 23, 2021 6:29 pm
by stefan.erni
Hi lucibel

I wrote a macro for leading space or leading zero in the AppDevelopper.

As a suggestion for number of char: (3)for byte, (5)for uinteger, (6)for sinteger, (10)for ulong, (11)for slong

Maybe it help a little

regards

Stefan
String_leading_space._post_1.fcsx
(12.85 KiB) Downloaded 396 times
leading_space_2021-12-23_19-09-51.png
leading_space_2021-12-23_19-09-51.png (70.84 KiB) Viewed 4437 times
leading_space_2021-12-23_19-11-54.png
leading_space_2021-12-23_19-11-54.png (130.21 KiB) Viewed 4437 times

Re: Print new number on screen and removing previous characters

Posted: Thu Dec 23, 2021 11:48 pm
by medelec35
If you would like to post your flowchart, I can add a couple of examples for you.

Re: Print new number on screen and removing previous characters

Posted: Fri Dec 24, 2021 8:44 am
by Xbiotec
Hi my data are currently numbers right now.
LeighM wrote:
Thu Dec 23, 2021 4:48 pm
Add a space character to the text string.
You might need to do that based on the string length.
So I used ToString$ then checked if number is more or less than 999 .
if more than 999 then add a space to the string.

It work well and was easy to do.
Thx LeighM

Re: Print new number on screen and removing previous characters

Posted: Fri Dec 24, 2021 8:57 am
by Xbiotec
Hi,
I can not send you the complete one who include EEPROM,webserver, networkcom,WLAN, 2 circularbuffers, 2 UARTS, RTC...
So I will send you a simple flowchart.
medelec35 wrote:
Thu Dec 23, 2021 11:48 pm
If you would like to post your flowchart, I can add a couple of examples for you.

Re: Print new number on screen and removing previous characters

Posted: Fri Dec 24, 2021 11:49 am
by medelec35
Hi.
A simple flowchart just displaying the numbers will be fine.