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;

33 REPLIES 33

Solved. I had to add

#include <gui/common/FrontendHeap.hpp>

in FrontendApplication.c

But you would not be able to call

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

from .c code. How could you circumvent that, could you write a c-calling convention compatible wrapper inside FrontEndApplication.cpp which would call gotoScreen1ScreenNoTransition() directly? Could this be for example done by writing a function outside the class that woudl have access to the instantiated object and place that between extern "c" brackets?

I wish that I could program everyghing in either .cpp or .c, but with FreeRTOS and TouchGFX one has little choice.

 

Martin,

I want to change from screen1 to screen2 in my Virtual Function.  How do I call:

gotoScreen1ScreenNoTransition();

From Screen1View?  

 

#include <gui/screen1_screen/Screen1View.hpp>
#include <gui_generated/common/FrontendApplicationBase.hpp>

void Screen1View::buttonClicked10s()
{


	buttonNumActive=10;
	//application().gotoScreen2ScreenNoTransition();
	static_cast<FrontendApplication*>(Application::getInstance())->gotoScreen2ScreenNoTransition();

}

 

 undefined reference to `Screen1View::gotoScreen2ScreenNoTransition()

Hello @FJB2069 ,

 

All the transitions are not created automatically. If you want to be able to call a function to change a screen, you first need to create an interaction with that screen change. So for instance, create an interaction to go from screen1 to screen 2.
You can see an example of it in this video .

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)