cancel
Showing results for 
Search instead for 
Did you mean: 

Screen Change from Code

Dfarr.1
Senior

I am trying to trigger a screen change from code. I have followed:

https://community.st.com/s/question/0D50X0000AaYMwM/how-to-implement-switchscreen-in-touchgfx

and

https://community.st.com/s/question/0D50X0000BTdnsASQR/how-can-i-change-screen-in-software

Both Q&A threads are incomplete and I haven't been able to get either of them working on my own.

I have my message queue passing messages from FreeRTOS across to touchGFX to notify of hardware button presses (no touch screen in this application). But the only way I have been able to trigger any screen changes is to define an an interaction in the Designer, then call it from the model using:

static_cast<FrontendApplication*>(Application::getInstance())->gotoScreenNameNoTransition();

I would prefer to not have to create "dummy" interactions in the designer which never get used. I want to create a goto for each of my screens, then call them from my model based on state changes in the system.

I would appreciate any help you can offer.

1 ACCEPTED SOLUTION

Accepted Solutions
Alexandre RENOUX
Principal

Hello,

Entirely by code is very complicated for now, we are working on a way to simplify this process.

The current way to do is as follows :

You create a change screen action ( you will call it from user code later on)0693W000004IFdtQAG.png

Then you create your interaction that performs a screen transition where the trigger is the call of your previously created action

0693W000004IFfVQAW.png

Then you simply call

goToInfoScreen();

This will automatically trigger the screen transition.

/Alexandre

View solution in original post

9 REPLIES 9
Alexandre RENOUX
Principal

Hello,

Entirely by code is very complicated for now, we are working on a way to simplify this process.

The current way to do is as follows :

You create a change screen action ( you will call it from user code later on)0693W000004IFdtQAG.png

Then you create your interaction that performs a screen transition where the trigger is the call of your previously created action

0693W000004IFfVQAW.png

Then you simply call

goToInfoScreen();

This will automatically trigger the screen transition.

/Alexandre

Dfarr.1
Senior

I was creating an unused screen and all my desired Go To Screen Interactions, all with "When screen is entered" as the trigger, then never actually entering the screen. Then I was using a cast to grab the FrontendApplication handle and calling the relevant auto-generated goto functions as I stated in my original post.

I was missing the Action as the trigger for the Interaction. That seems like it will be much cleaner than my janky cast.

I'll give it a try.

Thanks for the response.

Jiimmy
Associate II

Hi there

I am currently trying to do the same thing as discussed.

Working with version 4.19.1 I already managed to create a function as explained.

But when I want to call the function e.g.

goToInfoScreen();

In my model.cpp, I can not use the function, even though I include the following path:

#include <gui_generated/screencupremoved_screen/screenCupRemovedViewBase.hpp>

Where can I call my function, and what includes do I need?

Thank you for your answers.

Hi,

Why do you wish to call this function from the model ? The function created by TouchGFX Designer is set for a specific screen so you should call/set/modify it in this screen.hpp/cpp. What are you trying to do exactly ? There might be a better/healthier way to do it. I would also recommend to create a new post for better visibility.

/Romain

Jiimmy
Associate II

Hi Romain

Luckily, I already figured out my issue:

I tried to change the screen, when I was in the wrong view.

Maybe this helps someone else:

If you want to change to screen B, you need to call the screen-change function in screen A or just in the current screen. Now it sounds pretty logic to me, but I was kinda confused at the moment.

One thing stays a bit confusing: I now use the cryptic call:

static_cast<FrontendApplication*>(Application::getInstance())->gotoscreenScreenNoTransition();

The function generated in TouchGFX does not work for me. But this is even more comfortable for me, because I do not have to create actions for every screen in the TouchGFX Designer.

Cheers

Jimmy

justin11
Associate III

Hi, we are lookng to implement this also and hadn't realised it was so long winded just to swap a page from the code.

My Question is: If we have say 8 screens and we need to jump from any to any, do we have to goTo1Screen(); goTo2Screen(); goTo3Screen(); etc... on ever screen in TouchGFX to every screen? Or can these only be added to just the Home screen and be called from code regardless of the actual screen thats being displayed?

I created all my transitions on one screen that was never actually visited in my project just so there was a single point of maintenance. That was all I needed to get the goto's generated in code. From there I was able to call each goto from any other screen and they worked fine.

Hi, thanks for this.

I've added the goToInfoScreen(); as a test to my main application, but getting a "not been declared" error during the compile.

What #includes do i need to make sure are part of my main code to ensure the function can be linked to the touchgfx code ?

Cheers

Hello,

The call should look like application().goToInfoScreen(); instead of just goToInfoScreen() if that is the case. You should not need any specific include.

Have a look at the <screen name>ViewBase.cpp of the screen where you have added all the transitions to have a look at the change screen functions to also make sure to use the correct name.

/Romain