2023-07-03 02:59 PM
I 'm displaying a clock on my STM32F746 disco board and I run into a weird behavior that I can not explain. But I'm new to STM32. I have the RTC initialized to 10 hours, 1 minute and 50 seconds in BCD format. The seconds set to 50 is so I only wait 10s for the display to update after flashing the board. The RTC alarm A is set for every 60s. The alarm A callback function is called which notifies a task to run and update the time which in turn is passed to setTimeDate nTimeDate argument.
The view class (shown below) uptades the display. The hours, minutes, AM and PM are textboxes. Hours and minutes have each a wildcard. AM/PM don't have a wild card. The colons between the hours and minutes is a picture.
The default value after flashing in the display is 00:00 and both AM and PM are shown. After the 10s the clock shows the correct time (10:02 AM) but after that the PM shows up on every odd minute (see picture). Could someone point out what I'm doing wrong? Thanks.
void principalScreenView::setTimeDate(displayTimeDate_t nTimeDate)
{
// update hours and AM/PM ------------------
if(nTimeDate.hours > 0x12)
{
//hours between 0x12 and 0x23
nTimeDate.hours -= 0x12;
principalClockAM.setVisible(false); //erase AM
principalClockPM.setVisible(true); //draw PM
}
else
{
//hours between 0x0 and 0x11
principalClockAM.setVisible(true); //draw AM
principalClockPM.setVisible(false); //erase PM
}
// use "%x" (hex) to convert because they are BCD and need the hex value converted
// draw hours ------------------
Unicode::snprintf(principalClockHoursBuffer, PRINCIPALCLOCKHOURS_SIZE, "%x", nTimeDate.hours);
principalClockHours.invalidate();
// draw minutes ------------------
Unicode::snprintf(principalClockMinutesBuffer, PRINCIPALCLOCKMINUTES_SIZE , "%02x", nTimeDate.minutes);
principalClockMinutes.invalidate();
}
Solved! Go to Solution.
2023-07-03 11:46 PM
I would try to also invalidate
principalClockAM.invalidate();
and
principalClockPM.invalidate();
2023-07-03 11:46 PM
I would try to also invalidate
principalClockAM.invalidate();
and
principalClockPM.invalidate();