Skip to main content
Associate II
June 30, 2025
Solved

Call "change screen functions" in stm32h5xx_it file

  • June 30, 2025
  • 3 replies
  • 547 views

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

 

Best answer by ferro

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.

3 replies

TDK
Super User
June 30, 2025

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
Technical Moderator
July 2, 2025

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,

ferro
Lead
July 2, 2025

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

GaetanGodart
Technical Moderator
July 2, 2025

Yes, actually we can, let me change that.

ferro
Lead
July 2, 2025

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.