cancel
Showing results for 
Search instead for 
Did you mean: 

How can I change screen in software?

Yunus ARI
Senior

Hi everyone,

I want to change several screens between each other. I can do change screens with a trigger in the designer. When I do that the designer create a function in FrontendApplication. Maybe I can get this function and use in my function. But I have so many screen change with different trigger and transition.  And I don't want to create useless triggers in the designer for create change screen function in FrontendApplication.

How can I (or may I can) create a general function which use for change screen whichever I want. I tried copying and editing the function in FrontendApplication but I failed. Is there any easy way to do that?

Thanks already.

3 REPLIES 3
Martin KJELDSEN
Chief III

Hi,

You could make a general goto-function that called the functions generated by the designer:

...
    switch (screen)
    {
    case SCREEN1:
        static_cast<FrontendApplication*>(Application::getInstance())->gotoScreen1();
        break;
    case SCREEN2:
        static_cast<FrontendApplication*>(Application::getInstance())->gotoScreen2();
        break;
    case SCREEN3:
        static_cast<FrontendApplication*>(Application::getInstance())->gotoScreen3();
        break;
   ...

Yunus ARI
Senior

Hi,

Hi Martin,

I did research after ask this question and I find an answer from you in this post; "How to implement "SwitchScreen()" in touchgfx?"

When read this I've tried add my own function in gui/src/common/FrontEndApplication.cpp. Like you write now, I prepared a switch case. But a little bit different, like below;

void FrontendApplication::ChangeScreen(ScreenName_t screen)
{
 
    switch (screen) {
        case SCREEN1:
        transitionCallback = touchgfx::Callback<FrontendApplication>(this, &FrontendApplication::gotoScreen1Impl);
        break;
        
        case SCREEN2:
        transitionCallback = touchgfx::Callback<FrontendApplication>(this, &FrontendApplication::gotoScreen2Impl);
        break;
  
    }
    
    pendingScreenTransitionCallback = &transitionCallback;
}

Working on this right now. When this function is called, system go inside the function and do its work. But after that system not going "gotoScreen1Impl" functions. And screen not change for that reason. What I am supposed to do for solve this problem?

Edit;

I tried something else now. While I get this error, I called function as follows;

...
protected:
   FrontendApplication& application() {
        return *static_cast<FrontendApplication*>(Application::getInstance());
    }
...
 
...
application().ChangeScreen(SCREEN1);
...

Now I tried calling the function like you do.

...
static_cast<FrontendApplication*>(Application::getInstance())->ChangeScreen(SCREEN1);
...

When do that "gotoScreen1Impl" functions is work. But system give assert error on line 196 in "MVPApplication.hpp" file.

assert(sizeof(TransType) <= heap.transitionStorage.element_size() && "Transition allocation error: Check that all transitions are added to FrontendHeap::TransitionTypes");

I am going to trying something more while wait for your answer.😀

One more thing;

I add all transition myself in FrontendApplication.cpp file. FrontendApplicationBase file has just startup screen transition.