cancel
Showing results for 
Search instead for 
Did you mean: 

I would like to update clock on multiple screen where clock value i received from backend application Or from the model class

Nikunj Patel
Associate III

Hello @Martin KJELDSEN​ @Community member​ ,

I have STM32F746G Disco Board.

I have multiple screen in project and i would like to update the clock time on multiple screen.

so, I have used the "digitalclock" widget at 3 different screen.

I got the timing information from backend application but as of now, for testing purpose i have update timing from model class and update the information using "model->presenter->view".

But i am not able to update the timing in main screen.

======Model.cpp====

#include <gui/model/Model.hpp>

#include <gui/model/ModelListener.hpp>

Model::Model() : modelListener(0),tickCounter(0)

{

}

void Model::tick()

{

   tickCounter++;

   if (tickCounter % 60 == 0)

   {

       if (++digitalSeconds >= 60)

       {

           digitalSeconds = 0;

           if (++digitalMinutes >= 60)

           {

               digitalMinutes = 0;

               if (++digitalHours >= 24)

               {

                   digitalHours = 0;

               }

           }

       }

   }

}

char16_t Model::getHour()

{

   return digitalHours;

}

char16_t Model::getMinute()

{

   return digitalMinutes;

}

char16_t Model::getSecond()

{

   return digitalSeconds;

}

====presenter.cpp=====

#include <gui/mainscreen_screen/MainScreenView.hpp>

#include <gui/mainscreen_screen/MainScreenPresenter.hpp>

MainScreenPresenter::MainScreenPresenter(MainScreenView& v)

   : view(v)

{

}

void MainScreenPresenter::activate()

{

}

void MainScreenPresenter::deactivate()

{

}

int16_t MainScreenPresenter::getHour()

{

   return model->getHour();

}

int16_t MainScreenPresenter::getMinute()

{

   return model->getMinute();

}

int16_t MainScreenPresenter::getSecond()

{

   return model->getSecond();

}

======MainScreenView.cpp=======

#include <gui/mainscreen_screen/MainScreenView.hpp>

MainScreenView::MainScreenView()

{

}

void MainScreenView::setupScreen()

{

   MainScreenViewBase::setupScreen();

   digitalHours = digitalClock.getCurrentHour();

   digitalMinutes = digitalClock.getCurrentMinute();

   digitalSeconds = digitalClock.getCurrentSecond();

}

void MainScreenView::tearDownScreen()

{

   MainScreenViewBase::tearDownScreen();

}

void MainScreenView::updateClock()

{

   digitalHours = presenter->getHour();

   digitalMinutes = presenter->getMinute();

   digitalSeconds = presenter->getSecond();

   digitalClock.setTime24Hour(digitalHours, digitalMinutes, digitalSeconds);

}

Please, let me know where i have made mistake.

Thanks

Nikunj Patel

1 REPLY 1
Martin KJELDSEN
Chief III

when you say "But i am not able to update the timing in main screen." do you mean that you're able to update the other screens?

/Martin