Trying to update Label

Fully featured ARM compilers available on Windows, Linux, and macOS.
Post Reply
Author
Message
Add7ct7on
Posts: 3
Joined: 03 Feb 2020 11:55

Trying to update Label

#1 Post by Add7ct7on » 25 Jan 2021 22:25

Hi,

I am trying to redraw component with the below code, what am I doing wrong.

void main_screen_Action_OnClick_Button1()
{

main_screen.Label1 -> text.caption = "Hello World";

vtft_draw_component(_vtft, (vtft_component*)(&main_screen.Label1));
}

Add7ct7on
Posts: 3
Joined: 03 Feb 2020 11:55

Re: Trying to update Label

#2 Post by Add7ct7on » 27 Jan 2021 23:45

fixed
vtft_draw_component(_vtft, (vtft_component*)(&main_screen.Label1));
changed to this
vtft_draw_component(_vtft, (vtft_component*)(main_screen.Label1));

How is a label cleared?

R.Crane
Posts: 8
Joined: 15 Feb 2021 15:49

Re: Trying to update Label

#3 Post by R.Crane » 17 Feb 2021 21:27

Not trying to resurrect a dead post, but, did you ever find an answer to this question Addiction (be it yourself or through a support ticket)? I am also trying to solve this exact same problem with my own application lol - I am currently having to refresh the screen with a vtft_refresh_current_screen() function call in order to accomplish that, but it's kind of a half-measure since it's redrawing the -entire- screen which is not desirable for my app's intended usage.

R.Crane
Posts: 8
Joined: 15 Feb 2021 15:49

Re: Trying to update Label

#4 Post by R.Crane » 23 Feb 2021 21:58

For those interested, the way I am working around this is by drawing a box underneath my label - whenever I want to update my Label, I am drawing a box on top of the obsolete label.

Example:

vtft_draw_component(&vtft, xyz_screen.XBox);
vtft_draw_component(&vtft, xyz_screen.X);

Where XBox is my box for my X value, and X is my label. I do this for each Label I want to update.

Otherwise, I am calling...

vtft_refresh_current_screen(&vtft)

...every time I want to refresh the screen. Keep in mind this redraws the ENTIRE screen and ALL of its components - very slow, noticeably slower than just drawing smaller rectangles essentially over obsolete Labels. Couldn't find a way to just arbitrarily, dynamically change an already drawn label.

Hope this helps whoever else is running into this issue.

R.Crane
Posts: 8
Joined: 15 Feb 2021 15:49

Re: Trying to update Label

#5 Post by R.Crane » 23 Feb 2021 22:00

...Also important to note that for the above solution to work, in your scr_<my_screen>.h file, make sure that whatever you are redrawing via vtft_draw_component() is NOT a const variable.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Trying to update Label

#6 Post by filip » 25 Feb 2021 13:54

Hi,

You can also do something like this for example :

Code: Select all

gl_set_brush_style(GL_BRUSH_STYLE_FILL);
gl_set_brush_color(main_screen.screen_data->color);    
gl_set_pen(GL_BLACK,0);
gl_draw_rect(620,350,120,90);
vtft_draw_component(_vtft,(vtft_component *)main_screen.Label2);
Be sure to include gl.h in your source file.

Regards,
Filip.

darkglove
Posts: 3
Joined: 05 Nov 2021 15:01

Re: Trying to update Label

#7 Post by darkglove » 21 Nov 2021 09:13

Just want to be sure how this is working...

Does drawing a black rectangle over a label just update a section of the current "canvas"?

This doesn't mean that in the background I'm creating unseen children in the background every time I do this that will take up more and more memory and never be deleted?

Thanks

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Trying to update Label

#8 Post by filip » 24 Nov 2021 11:35

Hi,

The code will simply draw a filled rectangle over a desired label.

Regards,
Filip.

gojdic5678
Posts: 17
Joined: 27 Jan 2022 08:15

Re: Trying to update Label

#9 Post by gojdic5678 » 04 Mar 2022 15:16

filip wrote:
25 Feb 2021 13:54
Hi,

You can also do something like this for example :

Code: Select all

gl_set_brush_style(GL_BRUSH_STYLE_FILL);
gl_set_brush_color(main_screen.screen_data->color);    
gl_set_pen(GL_BLACK,0);
gl_draw_rect(620,350,120,90);
vtft_draw_component(_vtft,(vtft_component *)main_screen.Label2);
Be sure to include gl.h in your source file.

Regards,
Filip.
Works, as it updates to new label, but leaves both old and new label intertwined on screen. So you have to do the vtft_refresh_current_screen(_vtft); anyway. Am I missing something?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Trying to update Label

#10 Post by filip » 08 Mar 2022 14:05

Hi,

For now this is the only way.

Regards,
Filip.

Post Reply

Return to “ARM AI Compilers”