@@ -85,40 +85,34 @@ void WatchFaceDigital::Refresh() {
8585 lv_label_set_text_static (notificationIcon, NotificationIcon::GetIcon (notificationState.Get ()));
8686 }
8787
88- currentDateTime = dateTimeController.CurrentDateTime ();
88+ currentDateTime = std::chrono::time_point_cast<std::chrono::minutes>( dateTimeController.CurrentDateTime () );
8989
9090 if (currentDateTime.IsUpdated ()) {
91- auto hour = dateTimeController.Hours ();
92- auto minute = dateTimeController.Minutes ();
93- auto year = dateTimeController.Year ();
94- auto month = dateTimeController.Month ();
95- auto dayOfWeek = dateTimeController.DayOfWeek ();
96- auto day = dateTimeController.Day ();
97-
98- if (displayedHour != hour || displayedMinute != minute) {
99- displayedHour = hour;
100- displayedMinute = minute;
101-
102- if (settingsController.GetClockType () == Controllers::Settings::ClockType::H12) {
103- char ampmChar[3 ] = " AM" ;
104- if (hour == 0 ) {
105- hour = 12 ;
106- } else if (hour == 12 ) {
107- ampmChar[0 ] = ' P' ;
108- } else if (hour > 12 ) {
109- hour = hour - 12 ;
110- ampmChar[0 ] = ' P' ;
111- }
112- lv_label_set_text (label_time_ampm, ampmChar);
113- lv_label_set_text_fmt (label_time, " %2d:%02d" , hour, minute);
114- lv_obj_align (label_time, lv_scr_act (), LV_ALIGN_IN_RIGHT_MID, 0 , 0 );
115- } else {
116- lv_label_set_text_fmt (label_time, " %02d:%02d" , hour, minute);
117- lv_obj_align (label_time, lv_scr_act (), LV_ALIGN_CENTER, 0 , 0 );
91+ uint8_t hour = dateTimeController.Hours ();
92+ uint8_t minute = dateTimeController.Minutes ();
93+
94+ if (settingsController.GetClockType () == Controllers::Settings::ClockType::H12) {
95+ char ampmChar[3 ] = " AM" ;
96+ if (hour == 0 ) {
97+ hour = 12 ;
98+ } else if (hour == 12 ) {
99+ ampmChar[0 ] = ' P' ;
100+ } else if (hour > 12 ) {
101+ hour = hour - 12 ;
102+ ampmChar[0 ] = ' P' ;
118103 }
104+ lv_label_set_text (label_time_ampm, ampmChar);
105+ lv_label_set_text_fmt (label_time, " %2d:%02d" , hour, minute);
106+ lv_obj_align (label_time, lv_scr_act (), LV_ALIGN_IN_RIGHT_MID, 0 , 0 );
107+ } else {
108+ lv_label_set_text_fmt (label_time, " %02d:%02d" , hour, minute);
109+ lv_obj_align (label_time, lv_scr_act (), LV_ALIGN_CENTER, 0 , 0 );
119110 }
120111
121- if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
112+ currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get ());
113+ if (currentDate.IsUpdated ()) {
114+ uint16_t year = dateTimeController.Year ();
115+ uint8_t day = dateTimeController.Day ();
122116 if (settingsController.GetClockType () == Controllers::Settings::ClockType::H24) {
123117 lv_label_set_text_fmt (label_date,
124118 " %s %d %s %d" ,
@@ -135,11 +129,6 @@ void WatchFaceDigital::Refresh() {
135129 year);
136130 }
137131 lv_obj_realign (label_date);
138-
139- currentYear = year;
140- currentMonth = month;
141- currentDayOfWeek = dayOfWeek;
142- currentDay = day;
143132 }
144133 }
145134
0 commit comments