Erasing text on graphic LCD

For general Flowcode discussion that does not belong in the other sections.
jandidden
Posts: 113
http://meble-kuchenne.info.pl
Joined: Mon Feb 13, 2023 7:56 pm
Has thanked: 28 times
Been thanked: 12 times

Erasing text on graphic LCD

Post 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

mnfisher
Valued Contributor
Posts: 1546
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 737 times

Re: Erasing text on graphic LCD

Post by mnfisher »

Convert the number to a string, add a space at the end then print - with print background set to true.

Martin

jandidden
Posts: 113
Joined: Mon Feb 13, 2023 7:56 pm
Has thanked: 28 times
Been thanked: 12 times

Re: Erasing text on graphic LCD

Post 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

BenR
Matrix Staff
Posts: 1940
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 506 times
Been thanked: 688 times

Re: Erasing text on graphic LCD

Post 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.

jandidden
Posts: 113
Joined: Mon Feb 13, 2023 7:56 pm
Has thanked: 28 times
Been thanked: 12 times

Re: Erasing text on graphic LCD

Post 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

BenR
Matrix Staff
Posts: 1940
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 506 times
Been thanked: 688 times

Re: Erasing text on graphic LCD

Post 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.

jandidden
Posts: 113
Joined: Mon Feb 13, 2023 7:56 pm
Has thanked: 28 times
Been thanked: 12 times

Re: Erasing text on graphic LCD

Post 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

chipfryer27
Valued Contributor
Posts: 1604
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 357 times
Been thanked: 565 times

Re: Erasing text on graphic LCD

Post 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

mnfisher
Valued Contributor
Posts: 1546
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 737 times

Re: Erasing text on graphic LCD

Post 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

jandidden
Posts: 113
Joined: Mon Feb 13, 2023 7:56 pm
Has thanked: 28 times
Been thanked: 12 times

Re: Erasing text on graphic LCD

Post 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
Last edited by jandidden on Tue Jun 13, 2023 10:47 am, edited 1 time in total.

Post Reply