@@ -104,45 +104,33 @@ void WatchFaceTerminal::Refresh() {
104104 }
105105 }
106106
107- currentDateTime = dateTimeController.CurrentDateTime ();
108-
107+ currentDateTime = std::chrono::time_point_cast<std::chrono::seconds>(dateTimeController.CurrentDateTime ());
109108 if (currentDateTime.IsUpdated ()) {
110- auto hour = dateTimeController.Hours ();
111- auto minute = dateTimeController.Minutes ();
112- auto second = dateTimeController.Seconds ();
113- auto year = dateTimeController.Year ();
114- auto month = dateTimeController.Month ();
115- auto dayOfWeek = dateTimeController.DayOfWeek ();
116- auto day = dateTimeController.Day ();
117-
118- if (displayedHour != hour || displayedMinute != minute || displayedSecond != second) {
119- displayedHour = hour;
120- displayedMinute = minute;
121- displayedSecond = second;
122-
123- if (settingsController.GetClockType () == Controllers::Settings::ClockType::H12) {
124- char ampmChar[3 ] = " AM" ;
125- if (hour == 0 ) {
126- hour = 12 ;
127- } else if (hour == 12 ) {
128- ampmChar[0 ] = ' P' ;
129- } else if (hour > 12 ) {
130- hour = hour - 12 ;
131- ampmChar[0 ] = ' P' ;
132- }
133- lv_label_set_text_fmt (label_time, " [TIME]#11cc55 %02d:%02d:%02d %s#" , hour, minute, second, ampmChar);
134- } else {
135- lv_label_set_text_fmt (label_time, " [TIME]#11cc55 %02d:%02d:%02d" , hour, minute, second);
109+ uint8_t hour = dateTimeController.Hours ();
110+ uint8_t minute = dateTimeController.Minutes ();
111+ uint8_t second = dateTimeController.Seconds ();
112+
113+ if (settingsController.GetClockType () == Controllers::Settings::ClockType::H12) {
114+ char ampmChar[3 ] = " AM" ;
115+ if (hour == 0 ) {
116+ hour = 12 ;
117+ } else if (hour == 12 ) {
118+ ampmChar[0 ] = ' P' ;
119+ } else if (hour > 12 ) {
120+ hour = hour - 12 ;
121+ ampmChar[0 ] = ' P' ;
136122 }
123+ lv_label_set_text_fmt (label_time, " [TIME]#11cc55 %02d:%02d:%02d %s#" , hour, minute, second, ampmChar);
124+ } else {
125+ lv_label_set_text_fmt (label_time, " [TIME]#11cc55 %02d:%02d:%02d" , hour, minute, second);
137126 }
138127
139- if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
128+ currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get ());
129+ if (currentDate.IsUpdated ()) {
130+ uint16_t year = dateTimeController.Year ();
131+ Controllers::DateTime::Months month = dateTimeController.Month ();
132+ uint8_t day = dateTimeController.Day ();
140133 lv_label_set_text_fmt (label_date, " [DATE]#007fff %04d-%02d-%02d#" , short (year), char (month), char (day));
141-
142- currentYear = year;
143- currentMonth = month;
144- currentDayOfWeek = dayOfWeek;
145- currentDay = day;
146134 }
147135 }
148136
0 commit comments