How to implement "SwitchScreen()" in touchgfx?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-28 6:13 AM
Hello all,
I am trying to switch the screen throuch code in touchgfx.
If I use SwitchScreen, how shall I state the argument (screen* newScreen)?
If, for example I want to switch to Screen7.
Shall I call the function with SwitchScreen(scr7)?
where scr7 is declared as follows:
ScreenView7 scr7;
Solved! Go to Solution.
- Labels:
-
TouchGFX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-04 4:16 PM
Did you ever do the video for this. Are they any examples?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-05 12:12 AM
Hi,
I am unsure if Martin did a video on this, but I believe this one from Gustavo might help you. In this project he uses a hardware button to interact with his GUI (he makes a box widget appear/disappear). You can adapt his interaction to a screen transition if it is what you need.
Hope this helps.
/Romain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-05 12:17 PM
Many thanks for responding. That is useful information, but does not answer my specific question. I have an IMAGE when clicked that I would like to change the screen. As I cannot add an interaction to change screen based on the click of an IMAGE in the TouchGFX app I need to add a click-listener handle within the code. I have done that, and I can hit the designated breakpoint when I click the image. What I do not know how to do in the code is to switch to a different screen. Within gui_generated/src/common/FrontEndApplicationBase.cpp are the interactions for switching screens that were created within and by the TouchGFX application. Within gui/src/common/FrontEndApplication.cpp I am supposed to be able to write my own screen interactions which I then call from my touch listener handle. The issue is I do not know how to write an interaction to change screens. Can you please provide an example of this: Change to screen name "Screen_AD", Transistion = Wipe, Direction = East.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-06 7:37 AM
This does not answer the question directly but it is a work around that accomplishes pretty much the same thing. It will allow me to keep working and push figuring this out for another day. Just three simple steps within the touchGFX app is all that is necessary:
- Place your image (do not select the clicklistner option)
- Place a flexbutton widget over the image (size to match image)
- Add the interaction as you normally would for the flexbutton to change screen or do whatever
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-06 9:28 AM
Why can't you make an image into a button?
Just use the same image as both the clicked and unclicked source picture?
Anyway, the code you are probably looking for is:
static_cast<FrontendApplication*>(Application::getInstance())->gotoIDScreenScreenNoTransition();
Just make sure that the transition code is actually generated. If you have a screen that is only accessed programatically you need to make a button somewhere offscreen and add an interaction to that button. that way you have the interaction generated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-06 2:57 PM
Your solution is better. I am working my way through TouchGFX , I did not realize that was possible; now I see it. I played with the development board for a bit, now I have my own hardware. So I learn a little more each time. Thanks so much for responding. Now I have another way to get this done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-17 2:56 AM
Hi Martin,
I (think I) did what you suggested:
- in the Designer I generated a screen change to the screen I wanted to appear (only programmatically, not by UI interaction)
- I cut & pasted the generated methods from FrontendApplicationBase.cpp to FrontendApplication.cpp (applying the needed corrections to method names)
- I added this in the protected section of FrontendApplication.hpp
touchgfx::Callback<FrontendApplication> transitionCallback;
but I keep getting this compiler error:
invalid initialization of reference of type 'touchgfx::MVPHeap&' from expression of type 'FrontendHeap'
at this line
touchgfx::makeTransition<Screen_resetView, Screen_resetPresenter, touchgfx::NoTransition, Model >(¤tScreen, ¤tPresenter, frontendHeap, ¤tTransition, &model);
What am I missing?
Thanks in advance for your help,
Andrea
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-16 1:35 PM
I don't think I have the perfect answer, but here's my workaround:
How do you switch between screens from the Model.cpp?
Using the Application handle, I was able to change screens.
#include <gui/common/FrontendApplication.hpp>
void Model::forceScreenTransition(eScreenIndex_t const eScreenIndex)
{
FrontendApplication *const poApp = static_cast<FrontendApplication *>(Application::getInstance());
switch (eScreenIndex)
{
default:
case SCREEN_UNKNOWN: break; //< Do nothing.
case SCREEN_SELF_TEST: poApp->gotoSelfTestScreenNoTransition(); break;
case SCREEN_WAITING_CONNECTION: poApp->gotoWaitingConnectionScreenNoTransition(); break;
// etc ...
}
}
But what if the gotoMyScreen() function has not been generated?
For some reason, TouchGFX does not generate the transition functions for a screen without an interaction.
My workaround was to add a useless interaction (When hardware button is clicked, switch to <my screen>) to force TouchGFX Designer to generate the code in FrontendApplicationBase.cpp.
Hope it helps.
Sharing is caring.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-16 1:36 PM
See my reply for an idea. (3 years late, but maybe it will still be helpful)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-08 2:51 PM
I have done this step by step. Each step is committed and explained in git so you can see how to add very few lines of codes, test them and go ahead.
Last commit that enter SettingsMenu if user button is pushed is 0c571f9.
https://github.com/RPatriziDesign/STM32F769-DiscoProject01/network
Regards, Roberto
