cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Screen programmatically

Plaramee
Associate III

Hi, I have been trying to have my screen change from my own code.

Right now, I tried from another thread to do the following:

I have two screens that I currently alternate every 15 seconds.

    FrontendApplication* App;
    App = static_cast<FrontendApplication*>(Application::getInstance());
    uint8_t Screen = 1;
    while(1)
    {
        osDelay(15000);
        if(Screen == 0)
        {
            App->gotoStatus1ScreenNoTransition();
            Screen = 1;
        }
        else
        {
            App->gotoStatus2ScreenNoTransition();  
            Screen = 0;
        }
    }

My program starts with the Status1 screen displayed.

When my call to gotoStatus2ScreenNoTransition gets executed, the screen rarely gets refreshed. When it does, it gets refreshed after 10-12 seconds only. Most of the time it does not refresh at all during the 15 seconds delay. I only get a frozen Screen1 (Screen1 has information that scrolls and changes).

But as soon as the call to gotoStatus1ScreenNoTransition is executed, the screen is refreshed properly .

I know it is a hard to understand without the full context, but maybe someone can give a pointer to where to look to correct this? Is it the proper way of changing screens at runtime without any buttons or screen touches (our product does not have a touch screen anyway).

I also tried to change the screen in Model::tick() with the same result.

So where is the best place to put the screen changing code? What does need to be done except from calling the screen transition functions? Any redraw, invalidate or anything else needs to be called?

Thank you in advance for any response as I am puzzled with this right now.

1 ACCEPTED SOLUTION

Accepted Solutions
Plaramee
Associate III

Hi all,

just wanted to let everyone know that all my issues are solved.

Actually it was a mistake in the OSwrappers.cpp that was causing this weird behaviour. I had ported it myself from the FreeRTOS compatible version to use with keil RTX via CMSIS OS calls.

With 4.10, TouchGFX projects now include a CMSIS version of the OSwrappers file, I was able to notice the mistake (I was close though!) and fix it.

So thank you all for your insights!

View solution in original post

3 REPLIES 3
apll
Associate II

Hi,

you can use handleTickEvent for change screen every n second with a variable tick for count seconds

void Screen1View::handleTickEvent ()
{
   tick++;
 
   if(tick % (60 * 15) == 0 && tick > 0)
   {
 
     if(Screen == 0)
 
        {
 
            App->gotoStatus1ScreenNoTransition();
 
            Screen = 1;
 
        }
 
        else
 
        {
 
            App->gotoStatus2ScreenNoTransition();  
 
            Screen = 0;
 
        }
 
      tick = 0;
 
   }
 
}

Martin KJELDSEN
Chief III

Hi Plaramee,

TouchGFX Applications are based on the Model-View-Presenter pattern. When you change to a screen, there are a few ways of receiving updates. I'm guessing you have some code in your presenter that initializes your view - And this happens only once, correct, which is why you're seeing a very static view.

1) As @Community member​ says, you can override handleTickEvent which is called every time VSYNC is received to do something - Like asking your presenter for information and presenting that .

2) Define methods in your ModelListener interface (Presenters are modellisteners) and call those methods from your model when you receive a new signal from e.g. a task. The presenter will override the appropriate method from the ModelListener interface and then call a method on the view to update the graphical components depending on the received value.

Does that make sense? Otherwise don't hesitate to ask!

Best regards,

Martin

Plaramee
Associate III

Hi all,

just wanted to let everyone know that all my issues are solved.

Actually it was a mistake in the OSwrappers.cpp that was causing this weird behaviour. I had ported it myself from the FreeRTOS compatible version to use with keil RTX via CMSIS OS calls.

With 4.10, TouchGFX projects now include a CMSIS version of the OSwrappers file, I was able to notice the mistake (I was close though!) and fix it.

So thank you all for your insights!