cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement "SwitchScreen()" in touchgfx?

kvkhekale
Associate II

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;

31 REPLIES 31

I'm wondering about the same thing.

The TouchGFX team promised to come back with some video demos in the near future (as in the end of this month or so).

Please share if you found a solution for this problem.

I've got the project for this all lined up 🙂 Does exactly what you're describing. Will do a video on it asap.

* CubeMX: Configure GPIOS according to schematics

* TouchGFX HAL: Implement a function that can hand over hardware button press to TouchGFX application

* TouchGFX Designer: Map the value from HAL to Designer territory to be able to use the press as a trigger in an interaction.

/Martin

Second screen has no background = you're seeing garbage memory on target, and some weird state in the simulator.

FDeLu.1
Associate

Martin,

Have you released the video yet? If so please supply a link.

Thanks ​

Frank​

Hi @FDeLu.1​,

I already shot the video, yes, but i haven't edited it yet. Has to follow company protocols, etc. I did it as a one-take to save time and i'm just considering if i'm happy with releasing it.

/Martin

FDeLu.1
Associate

​OK please post the link once released. 

Also is it OK to call another screen from the view or should it be done from the presenter or model?  In a splash screen tick handler we have a timing loop that keeps the screen active for a couple seconds then calls "static_cast<FrontendApplication*>(Application::getInstance())_>gotoHomeScreenNoTransition();" from the handler.  Is that the correct place to call for the screen change or should it be done elsewhere?

Thanks,

Frank

@FDeLu.1​ 

Where did you end up doing calling your screen transitions? I am attempting doing it in a message handler in FrontendApplication.cpp.

@Martin KJELDSEN​  I am currently looking at implementing a message queue (from main.c) to send the TouchGFX task messages. These messages will be different dependent on the current screen being viewed. I was thinking putting this message handler in a common area such as FrontendApplication.cpp. Or would the model class be best place to do this?

You should probably use Model::tick() to inspect message queues and react accordingly, in order to have the logic bundled nicely together.

/Martin

Thanks Martin

mibra.1
Associate II
  • HI All,

I'm having a similar issue regarding switching screen.

in My GUI, i have Screen one and Screen two,

1- in screen one i set an interaction for changing the current screen (to screen two) by hardware button and i generated the code correctly and i found the next API

//Handles when a key is pressed

void Screen1ViewBase::handleKeyEvent(uint8_t key)

{

  if(0 == key)

  {

    application().gotoScreen2CoverTransitionEast();

  }

}

2- i used this handleKeyEvent(0) (in certain event) , in the screen1 view, but i didn't succeed to switch the screen2.

3- after debugging , i found that i actually go to the screen two setupScreen, the screen doesn't appear on the lcd.

Q: i want how ask how to use handleKeyEvent() properly ? do i use it in the screen view or the presenter or the model?