cancel
Showing results for 
Search instead for 
Did you mean: 

The digital clock resets to its initial value when we transition between screens

Mk.31
Associate III

Hi Team,

I'm using a digital clock widget to display time, I'm setting some initial value for the time to start like16:00:00 from there I'm starting to increment the time value which I need to display in the display, which will happen when I'm on that particular screen.

After 2 min (now time value is 16:02:00) when I transitioned to another screen and come back again to where I used the digital clock widget the value resets to 16:00:00 which shouldn't happen.

How to resolve the issue where I can get the updated value even though screen transition happens. please suggest a solution.

referred digital clock section in the support.touchgfx.com

3 REPLIES 3
Romain DIELEMAN
ST Employee

Hi,

When you exit a screen you "destroy it", and recreate it when landing on that screen again. What you need to do is save the data in the model class so that you can share it to other screens or save its value. I would suggest to have a look at the Tutorial 3 which seems to be similar to what you are trying to do: instead of setting the time values you want to save them. There are some sample code to understand how to "save/share" data thanks to the MVP design pattern.

/Romain

Watch out that you should implement the tick event again in the screen you are going to in order to update the timer, otherwise you will just go back to the time when you left the screen. I guess you could do it directly in the model as well, not 100% sure about the workflow.

/Romain

MM..1
Chief

From other end, examples for clock digital or analog explain how to show it, but holding and manage time data is precisely in RTC chip as in PLL variable clock.

For some timers for example downcount minutes is preffered use simply screen or model tick math, but for clock daytime is better RTC.

Set RTC in main and in screen read it.