cancel
Showing results for 
Search instead for 
Did you mean: 

Call "change screen functions" in stm32h5xx_it file

matheuschiarelli
Associate II

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.

matheuschiarelli_1-1751309822993.png

matheuschiarelli_2-1751310068015.png

 

8 REPLIES 8
TDK
Super User

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.

If you feel a post has answered your question, please click "Accept as Solution".
GaetanGodart
ST Employee

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:

GaetanGodart_0-1751455924295.png
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,

Gaetan Godart
Software engineer at ST (TouchGFX)

>>"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.

Yes, actually we can, let me change that.

Gaetan Godart
Software engineer at ST (TouchGFX)
ferro
Lead

Hi @matheuschiarelli 

there is

application().appSwitchScreen ( screenId );

in \touchgfx\framework\include\touchgfx\Application.hpp

ferro_0-1751462691025.png

This approach assumes that GoToYourScreen () is/are already present.

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!

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.

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,

Gaetan Godart
Software engineer at ST (TouchGFX)