Skip to main content
HAnh
Associate III
Aug 16, 2020 11:12 AM UTC
Solved

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

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

This topic has been closed for replies.
Romain DIELEMAN
Romain DIELEMANBest answer
ST Employee
Aug 21, 2020 9:44 AM UTC

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

8 replies

MM..1
Super User
Aug 16, 2020 12:20 PM UTC

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

HAnh
HAnhAuthor
Associate III
Aug 16, 2020 1:22 PM UTC

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
Super User
Aug 17, 2020 3:47 PM UTC

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
HAnhAuthor
Associate III
Aug 18, 2020 6:39 AM UTC

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
Super User
Aug 19, 2020 3:15 PM UTC

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
HAnhAuthor
Associate III
Aug 20, 2020 7:39 AM UTC

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
Super User
Aug 20, 2020 2:55 PM UTC

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
Romain DIELEMANBest answer
ST Employee
Aug 21, 2020 9:44 AM UTC

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