Custom Container on multiple screen : set DigitalClock problem [solved]
Hello,
I'm currently in the process of creating a Custom Container top bar (Banner) with a clock (and other values like text with wildcard) that propagates through the screens. But I hit a dead end days ago and I cannot find the solution.
Step 1: The fake hardware sets the time
Step 2: I propagate it to the model
Step 3: I propagate it to the presenter of the first screen
Step 4 : I propagate it to the custom container Banner present on all my screens. → That's where I have my problem.
The problem:
The clock updates to the time I set in my Hardware for a second, then the next second (60 ticks), it is set to 00:00:01 (first second passed) and when I change screen, the clock propagates as I want to but with the basis of the first screen aka 00:00:01.
I've based the application mainly on this ST post and glanced info in other posts but I can't manage to make my app work :
Here's the Screen1View.cpp code where I update my Clock in the Banner.
Screen1View::Screen1View()
{
}
void Screen1View::setupScreen()
{
Screen1ViewBase::setupScreen();
clockscreen1 = presenter->getTimePres();
banner.setTime(clockscreen1);
}
void Screen1View::tearDownScreen()
{
Screen1ViewBase::tearDownScreen();
}Here's my Custom container BannerBase.cpp
BannerBase::BannerBase()
{
setWidth(289);
setHeight(72);
digitalClock.setPosition(0, 0, 289, 72);
digitalClock.setColor(touchgfx::Color::getColorFromRGB(0, 0, 0));
digitalClock.setTypedText(touchgfx::TypedText(T___SINGLEUSE_BIUJ));
digitalClock.displayLeadingZeroForHourIndicator(true);
digitalClock.setDisplayMode(touchgfx::DigitalClock::DISPLAY_24_HOUR);
digitalClock.setTime24Hour(10, 10, 0);
add(digitalClock);
}
BannerBase::~BannerBase()
{
}
void BannerBase::initialize()
{
}
Here's the Banner.hpp
class Banner : public BannerBase
{
public:
Banner();
virtual ~Banner() {}
virtual void initialize();
virtual void handleTickEvent();
virtual void setTime(MyClock value);
protected:
int tickCounter;
int digitalHours;
int digitalMinutes;
int digitalSeconds;
};And the Banner.cpp
Banner::Banner()
{
touchgfx::Application::getInstance()->registerTimerWidget(this);
// digitalHours = digitalClock.getCurrentHour();
// digitalMinutes = digitalClock.getCurrentMinute();
// digitalSeconds = digitalClock.getCurrentSecond();
digitalClock.setTime24Hour(digitalHours, digitalMinutes, digitalSeconds);
}
void Banner::initialize()
{
BannerBase::initialize();
}
// Rajout Clock
void Banner::handleTickEvent()
{
tickCounter++;
if (tickCounter % 60 == 0)
{
if (++digitalSeconds >= 60)
{
digitalSeconds = 0;
if (++digitalMinutes >= 60)
{
digitalMinutes = 0;
if (++digitalHours >= 24)
{
digitalHours = 0;
} // End hours
} // End minutes
} // End seconds
// Update the clocks
digitalClock.setTime24Hour(digitalHours, digitalMinutes, digitalSeconds);
} // End modulo
}
void Banner::setTime(MyClock value)
{
digitalClock.setTime24Hour(value.hour, value.minute, value.second);
}My guess is I would need to put something in the initialize of the Banner but I cannot find what exactly or why my clock is set back to 00:00:00 ... probably related to
touchgfx::Application::getInstance()->registerTimerWidget(this);
digitalClock.setTime24Hour(digitalHours, digitalMinutes, digitalSeconds);I also have a fear that the BannerBase will set my clock to 10:10:00 and I do not want that either. How can I prevent this?
If possible, I would like to keep using the registerTimerWidget since I don't wanna update each screen (there's a lot of them) I would only set up the time in my first screen. If really not possible, how can I set my 1st screen right (the time I asked in my hardware is set and not 00:00:00) and I'll save it to the model and update it in screen 2. And I fear the time I propagate it to the model and update it in screen 2, I would have missed some ticks so my time would begin to drift.
I have also read that it was planned to insert a feature in a new version of TouchGFX where we would be able to group functionalities used in several screens (like containers) to not repeat the code. Any news on this feature? It seems really interesting.
Thanks in advance for your answer,
Eve
