Skip to main content
Associate II
January 22, 2025
Solved

TouchGFX update widget data from main() non-RTOS

  • January 22, 2025
  • 2 replies
  • 1638 views

I've created a TouchGFX project for an LTDC LCD with a H7a3 Nucleo board.  The project includes a static graph displayed on the LCD.  The project will compile, run and properly display the TouchGFX designed screen with the static graph. 

Next step would be to change the data on the graph from my custom code during run-time - possibly triggered from the button on the Nucleo.  However, I find a dead-end since main.c only has: #include "app_touchgfx.h" and cannot see a path to Model, Presenter or View classes.  I can't understand how any of the generated touchgfx code is referenced back to main.c. 

How do I call graph1.addpoint() from main()?  Indirectly or directly.  Or, maybe call from model:tick()??

How is the touchGFX code able to compile without references to all the TouchGFX code from main.c?  More importantly, how to access the screen objects in code without any references to it from user code (main.c)??

Are there any TouchGFX examples which update widget data from within the user code that do NOT use RTOS?  I've seen mentions of implementing the "OS Wrappers" when not using RTOS, but how?  Seamless?? 

Best answer by GaetanGodart

Hello @SJR1 and welcome to the community!

 

If I understood correctly, you want to update a graph based on some changes that happens on the main without using the RTOS.

All you have to do it to include main.h inside the model.cpp.
This way you can access the data stored in the main.
So if a data is added, you can have a bool to know if there is a new data and have h value as an int.
In the model.cpp, add the handleTickEvent function that is called every ticks (usually 60 times per second) and check the value of the bool to know if you have to add the new data point or not.

You can see an example of this type of implementation in this video .

 

If this answers your question, I invite you to select this comment as "best answer".

 

Regards,

2 replies

GaetanGodart
GaetanGodartBest answer
Technical Moderator
January 23, 2025

Hello @SJR1 and welcome to the community!

 

If I understood correctly, you want to update a graph based on some changes that happens on the main without using the RTOS.

All you have to do it to include main.h inside the model.cpp.
This way you can access the data stored in the main.
So if a data is added, you can have a bool to know if there is a new data and have h value as an int.
In the model.cpp, add the handleTickEvent function that is called every ticks (usually 60 times per second) and check the value of the bool to know if you have to add the new data point or not.

You can see an example of this type of implementation in this video .

 

If this answers your question, I invite you to select this comment as "best answer".

 

Regards,

SJR1Author
Associate II
January 24, 2025

Thanks for your reply!  I was close, but didn't see the path from Model to View class thru the Presenter class.  The video helps make this more clear and closes the loop for me.

GaetanGodart
Technical Moderator
February 3, 2025

Hello @SJR1 ;

 

I am glad it helped you!
Happy coding!

 

Regards,