2020-05-28 06:57 AM
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
2020-05-28 11:58 PM
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