Page 1 of 2
Erasing text on graphic LCD
Posted: Fri Jun 09, 2023 8:38 am
by jandidden
If you want to update a text or a number at a specific location on a graphic LCD, you must first erase the old text/number.
The way I am doing it at the moment is as follow:
- set the foregroundcolor to the backgroundcolor;
- print the old text, which effectively makes it invisible;
- set the foregroundcolor back to what it was;
- print the updated text/number.
That works, but it 'feels' convoluted.
Does anyone know of a simpler way?
Jan
Re: Erasing text on graphic LCD
Posted: Fri Jun 09, 2023 8:49 am
by mnfisher
Convert the number to a string, add a space at the end then print - with print background set to true.
Martin
Re: Erasing text on graphic LCD
Posted: Fri Jun 09, 2023 9:38 am
by jandidden
Yes that works, in my case adding two spaces as the numbers range from 0 to 320 (display resolution) and printing is left-justified.
Thanks.
Jan
Re: Erasing text on graphic LCD
Posted: Fri Jun 09, 2023 11:22 am
by BenR
The display manager component allows you to define a text area and then when you set the text in the area with a string it should clear the rest of the area for you. Might be useful.
This way it also allows you to define the X,Y coordinate in a single place and then print to the defined space throughout your program without having to keep recalling the coordinates.
Re: Erasing text on graphic LCD
Posted: Mon Jun 12, 2023 12:29 pm
by jandidden
Ben do you mean a function in the component? I don't see it there.
Is there a separate Display Manager somewhere?
Jan
Re: Erasing text on graphic LCD
Posted: Mon Jun 12, 2023 2:10 pm
by BenR
Hi Jan,
Yes under displays component toolbar, right at the bottom of the list there is a Display Manager component. You need to connect it to the GLCD component and then define the area you want to draw.
Re: Erasing text on graphic LCD
Posted: Tue Jun 13, 2023 7:54 am
by jandidden
Ben a follow-up to the Display Manager if I may.
I was looking at a way to 'page' the display.
Like when switching between an operational screen and a setup screen.
I was thinking I could save a whole screen to memory, display the other screen and then recall the first screen.
Mem wise it would need about 230kByte assuming 3 bytes (color) per pixel, for a complete screen, doable.
Except that I don't see anything in the component that would support reading an individual pixel color.
Maybe RedrawAll from the Display Manager would support that, assuming everything on the display is created with it.
Needs a separate text redraw apparently.
Or is there a simpler way to do this that I'm missing?
Jan
Re: Erasing text on graphic LCD
Posted: Tue Jun 13, 2023 8:26 am
by chipfryer27
Hi
Probably doable but it seems you are eating up memory.
What about just having two branches?
Branch one with B1 variables writes your operational screen with whatever background and fixed graphics etc whilst branch two with B2 variables writes your setup screen? As long as you didn't change any variable, when rewriting that branch again it would appear as before.
Regards
Re: Erasing text on graphic LCD
Posted: Tue Jun 13, 2023 9:44 am
by mnfisher
It is possible to buffer the display I did it for a demo here
viewtopic.php?f=10&t=1569&p=9135&hilit=Cheeting#p9135
However you need to use less bit depth- - I used 2,4 and 8 bit versions to fit in the available memory (on esp32)
You could use a similar technique to buffer part of the display.
Martin
Re: Erasing text on graphic LCD
Posted: Tue Jun 13, 2023 9:54 am
by jandidden
chipfryer27 wrote: ↑Tue Jun 13, 2023 8:26 am
Hi
Probably doable but it seems you are eating up memory.
What about just having two branches?
Branch one with B1 variables writes your operational screen with whatever background and fixed graphics etc whilst branch two with B2 variables writes your setup screen? As long as you didn't change any variable, when rewriting that branch again it would appear as before.
Regards
OK, but as each screen is dynamically changing in this part, then that part, this solution means I need to either redraw the complete screen with any change, or somehow keep track on each change for the case I have to redraw the whole screen.
Right?
Edit - an array of display objects would be a good solution but I don't think FC supports that.
Jan