cancel
Showing results for 
Search instead for 
Did you mean: 

How to increase seconds (RTC time) in 2 screens at the same time

HAnh
Associate III

I had build 2 screens (screen 1 and screen 2)

in each screen i place 2 text (using wildcard) with purpose display Time Minute and Time Second form RTC.

i had success in the first screen (screen 1), but i want to when i change to screen 2, the Time Minute and Time Second counter and display constantly from screen 1. Absolutely when i change from screen 2 to screen on it must same above concept.

i had code the same code for the screen 2, but when i change from screen 1 to screen 2, it is hanged.

So how can i solve that problem, that means i how can i update and show Time minute and Time Second when i change between 2 screen.

Thanks everyone

1 ACCEPTED SOLUTION

Accepted Solutions
Romain DIELEMAN
ST Employee

Hi, here is the link to that tutorial in the official documentation in case the other link is taken down one day.

View solution in original post

8 REPLIES 8
MM..1
Chief II

You need explain where you make refresh, in model or screen tick?

HAnh
Associate III

Hi MM..1

in main.c i had Stask and send semaphore to update Time.

in Model::Tick when i receive semaphore from main.c i will do: modelListener->timeUpdate

in Presenter::screen1 i will update by view.temperatureUpdate.

all process above run normally in screen 1

but when i make same function in screen2 Presenter::screen2 update by view.temperatureUpdate.

it can't run and hang.

MM..1
Chief II

Why you need semaphore, this when bad used can hang your code.

Simple way is use if visible and in if check if new time need refresh.

Why task for this, simplest is hw timer or tick counter or get rtc ...

HAnh
Associate III

Hi MM..1.

I'm using get RTC from Stm32f746.

I used Stask with purpose will get RTC every 3 second..

I used semaphore in the model.ccp to update RTC time to screen view 1, and screen view 2.

If i don't semaphore to synchronous data between model.ccp and view.ccp. wich ways i can do it.

I had make global variable connected from main.c, model.ccp, and view.ccp, but when i access this avariable from screen setup. It will hange.

MM..1
Chief II

Hi HAnh,

you dont need task for this.

Simply in

void Screen1View::handleTickEvent()

{

tickCounter++;

if(tickCounter%XX) && isVisible...) {

getRTC

showRTCscr1

}

void Screen2View::handleTickEvent()

{

tickCounter++;

if(tickCounter%XX) && isVisible...) {

getRTC

showRTCscr2

}

HAnh
Associate III

Hi MM..1.

Thanks for your support.

But i can't find tickCounter in Screen1View1 and screenView2.

beside that how i can create handleTickEvent() function?

How long for every handleTickEvent() happend?

Thanks

MM..1
Chief II

You need understand how screen refresh work, read https://touchgfx.zendesk.com/hc/en-us/articles/360018667192-Step-1-Setting-up-the-two-Screens

Simply virtual function is called on every refresh frame on display, based on Hz speed .

Romain DIELEMAN
ST Employee

Hi, here is the link to that tutorial in the official documentation in case the other link is taken down one day.