cancel
Showing results for 
Search instead for 
Did you mean: 

How to display the same content in different screen of touchgfx?

Junde
Senior II

Hi there,

I have a project with a display, and I want to show several screens.

All the screens have a time text at the top-left corner.

I know I can put a TextArea on all the screens, which means each one needs some memory to store the time value.

Is there any way, I can store the time in just one time, and display the time on any screen?

Thanks for your help!

1 ACCEPTED SOLUTION

Accepted Solutions

Yes, i created functions in the container and call the functions from all my views.

A general call would be great, but i think for that a lot rework needs to be done in the touchgfx structure.

Create functions for updating values and for show or hide images.

i.e. container:

void TopValue::updateValues(int value
{
	Unicode::snprintfFloat(txtValueBuffer, TXTVALUE_SIZE, "\%.f", value);
	txtValue.invalidate();
}

and in view i have some functions which are called by the main task, or you can use the handle tick event to update the top container:

topValue.updateValues(variableToUpdate);

Could be easier but once its done, thats ok. I created a template page and copied that for all new pages i created before implementing other functions.

View solution in original post

6 REPLIES 6
Exit0815
Senior

I am using a container for "header" stuff which is visible on multiple pages.

then i update the value for the text areas in the container in each single view i need it.

Did not find any other way.

GaetanGodart
ST Employee

Hello @Junde ,

 

If you are just concerned about memory space, you can simply save your time in the model.cpp and access it from any screen. This way, you store your data only once.

Also, as @Exit0815 said, it is a common practice to have a "header" (a custom container fitting your need) present on every screen and fetching its data from the model.cpp.

 

I hope this help! :smiling_face_with_smiling_eyes:
If this comment or another one answered your question, I invite you to select it as "best answer".

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

@Exit0815  @GaetanGodart 

thanks for your reply, it's help me a lot!

If the header also need some image to show the remainder battery.

Is this way can work out?

 

Yes, i created functions in the container and call the functions from all my views.

A general call would be great, but i think for that a lot rework needs to be done in the touchgfx structure.

Create functions for updating values and for show or hide images.

i.e. container:

void TopValue::updateValues(int value
{
	Unicode::snprintfFloat(txtValueBuffer, TXTVALUE_SIZE, "\%.f", value);
	txtValue.invalidate();
}

and in view i have some functions which are called by the main task, or you can use the handle tick event to update the top container:

topValue.updateValues(variableToUpdate);

Could be easier but once its done, thats ok. I created a template page and copied that for all new pages i created before implementing other functions.

Thanks for your advices

Hello @Junde ,

 

Yes, it would work too. When starting your screen, you will have to show the correct image according the the battery value. All the images are accessible from every screen. Look at this forum post to see how to change an image at runtime : change-image-at-runtime .

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)