Skip to main content
PKunK.1
Associate III
April 7, 2021
Solved

How to move the Screen from Model::tick() in a TouchGFX environment?

  • April 7, 2021
  • 4 replies
  • 1485 views

In the TouchGFX program, there are Model, A_Screen, and B_Screen.

It's working in A_Screen, and it's working in Model::tick()

When I have time, I want to move the screen to B_Screen.

To do this, I want to know what to do in Model::tick() to switch from A_Screen to B_Screen.

If anyone knows how, ask me for advice.

Thank you.

This topic has been closed for replies.
Best answer by Michael K

Here's what I did.

  1. I was too lazy to write the screen switch code myself, so I made dummy interactions on one of my pages to switch to each of my screens in response to a hardware button press (which I don't implement). TouchGFX will automatically create methods in FrontendApplicationBase
  2. Call the following code from wherever you want to switch to your new screen, replacing <screenName> and "NoTransition" as required with whatever the automatically generated method was called.
static_cast<FrontendApplication*>(Application::getInstance())->goto<screenName>ScreenNoTransition();

4 replies

Michael K
Michael KBest answer
Senior III
April 7, 2021

Here's what I did.

  1. I was too lazy to write the screen switch code myself, so I made dummy interactions on one of my pages to switch to each of my screens in response to a hardware button press (which I don't implement). TouchGFX will automatically create methods in FrontendApplicationBase
  2. Call the following code from wherever you want to switch to your new screen, replacing <screenName> and "NoTransition" as required with whatever the automatically generated method was called.
static_cast<FrontendApplication*>(Application::getInstance())->goto<screenName>ScreenNoTransition();

Embedded UI/UX Consulting: cadenza.design
PKunK.1
PKunK.1Author
Associate III
April 8, 2021

Thank you for teaching me a good way.

I found another way, similar to what you told me.

1. Create a button on the B_Screen (this button has an invisible property). Insert the code that switches the screen to B_Screen using the button function.

2. Copy the class of B_Screen to model.c and call the button made by B_Screen using the class copied.

I did it this way, but I checked that I was doing the action I wanted.

I will test again the way you told me.

Thank you so much from the bottom of my heart

Romain DIELEMAN
ST Employee
April 8, 2021

I'll chip in just to say that I do this as well, it is more than fine but I agree that Michael's solution is cleaner :grinning_face_with_sweat: either with a dummy hardware button or a dummy widget button that i put outside of the canvas.

/Romain