2025-06-30 12:07 PM
Hello, it is possible to call a function to change screens in a "stm32h5xx_it.c" file?
The goal here is redirect user to a different screen globally, with no need to do this in every screen individually. This function is called in "EXTI15_IRQHandler(void)" in the same file, which is a hardware button of mine.
2025-06-30 3:27 PM
Generally, calling blocking functions and other higher level functions shouldn't be done within an interrupt to avoid race conditions and functions that are not re-entrant safe. If you're in the middle of a display change and then this interrupt fires, my guess is it would break things.
Set a flag in the interrupt and change the screen in the main thread in response to this flag.
2025-07-02 4:34 AM - edited 2025-07-02 5:33 AM
Hello @matheuschiarelli ,
If you want to change screen in code, you need to generate the functions for it.
If you create 2 screens and you add an interaction to switch from screen1 to screen2, TouchGFX Generator will generate the function for that in the screen1 cpp base file:
Then, you can call that function yourself.
But you need to know which screen you are in right now to be able to call the correct function with something like:
application().gotoScreen2ScreenNoTransition();
Regards,
2025-07-02 4:51 AM
>>"There is no way to go from any screen to screen 2"
@GaetanGodart Could you please clarify this? With, say, 5 screens, you can switch between any of them freely, right? I’m probably misunderstanding what you meant.
2025-07-02 5:32 AM
Yes, actually we can, let me change that.
2025-07-02 6:29 AM
there is
application().appSwitchScreen ( screenId );
in \touchgfx\framework\include\touchgfx\Application.hpp
This approach assumes that GoToYourScreen () is/are already present.
2025-07-02 7:05 AM - edited 2025-07-02 7:07 AM
Hello @GaetanGodart and @ferro
Okay, i'm doing this at the moment. I was hoping to find a solution where i can call change screen functions outside touchgfx files, but if this isn't possible i will follow that way!
2025-07-02 7:09 AM - edited 2025-07-02 7:12 AM
yes, what I suggest does exactly what you want
appSwitchScreen ()
EDIT: actually GotoScreen () are also avaialble 'from any application code' via access to Application () instance.
2025-07-02 7:09 AM
You can ask to change screen in whatever other file, just follow TDK's guideline.
You could change a variable when you want to change screen and read that variable in HandleTickFunction of the model.ccp file or you could use the RTOS (if you use one) semaphores/queue to call the function to change the screen.
Regards,