Skip to main content
Junde
Senior III
September 24, 2024
Solved

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

  • September 24, 2024
  • 2 replies
  • 1797 views

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!

Best answer by Exit0815

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.

2 replies

Exit0815
Senior
September 24, 2024

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
Technical Moderator
September 24, 2024

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,

Junde
JundeAuthor
Senior III
September 29, 2024

@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?

 

Exit0815
Exit0815Best answer
Senior
September 29, 2024

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.