@@ -397,63 +397,37 @@ void WatchFaceInfineat::Refresh() {
397397 lv_obj_align (notificationIcon, lv_scr_act (), LV_ALIGN_IN_TOP_RIGHT, 0 , 0 );
398398 }
399399
400- currentDateTime = dateTimeController.CurrentDateTime ();
401-
400+ currentDateTime = std::chrono::time_point_cast<std::chrono::minutes>(dateTimeController.CurrentDateTime ());
402401 if (currentDateTime.IsUpdated ()) {
403- auto hour = dateTimeController.Hours ();
404- auto minute = dateTimeController.Minutes ();
405- auto year = dateTimeController.Year ();
406- auto month = dateTimeController.Month ();
407- auto dayOfWeek = dateTimeController.DayOfWeek ();
408- auto day = dateTimeController.Day ();
409-
410- char minutesChar[3 ];
411- sprintf (minutesChar, " %02d" , static_cast <int >(minute));
412-
413- char hoursChar[3 ];
414- char ampmChar[3 ];
402+ uint8_t hour = dateTimeController.Hours ();
403+ uint8_t minute = dateTimeController.Minutes ();
415404
416405 if (settingsController.GetClockType () == Controllers::Settings::ClockType::H12) {
417- if (hour < 12 ) {
418- if (hour == 0 ) {
419- hour = 12 ;
420- }
421- sprintf (ampmChar, " AM" );
422- } else { // hour >= 12
423- if (hour != 12 ) {
424- hour = hour - 12 ;
425- }
426- sprintf (ampmChar, " PM" );
406+ char ampmChar[3 ] = " AM" ;
407+ if (hour == 0 ) {
408+ hour = 12 ;
409+ } else if (hour == 12 ) {
410+ ampmChar[0 ] = ' P' ;
411+ } else if (hour > 12 ) {
412+ hour = hour - 12 ;
413+ ampmChar[0 ] = ' P' ;
427414 }
415+ lv_label_set_text (labelTimeAmPm, ampmChar);
428416 }
429- sprintf (hoursChar, " %02d" , hour);
430-
431- if ((hoursChar[0 ] != displayedChar[0 ]) || (hoursChar[1 ] != displayedChar[1 ]) || (minutesChar[0 ] != displayedChar[2 ]) ||
432- (minutesChar[1 ] != displayedChar[3 ])) {
433- displayedChar[0 ] = hoursChar[0 ];
434- displayedChar[1 ] = hoursChar[1 ];
435- displayedChar[2 ] = minutesChar[0 ];
436- displayedChar[3 ] = minutesChar[1 ];
437-
438- lv_label_set_text_fmt (labelHour, " %s" , hoursChar);
439- lv_label_set_text_fmt (labelMinutes, " %s" , minutesChar);
440- }
417+ lv_label_set_text_fmt (labelHour, " %02d" , hour);
418+ lv_label_set_text_fmt (labelMinutes, " %02d" , minute);
441419
442420 if (settingsController.GetClockType () == Controllers::Settings::ClockType::H12) {
443- lv_label_set_text (labelTimeAmPm, ampmChar);
444421 lv_obj_align (labelTimeAmPm, timeContainer, LV_ALIGN_OUT_RIGHT_TOP, 0 , 10 );
445422 lv_obj_align (labelHour, timeContainer, LV_ALIGN_IN_TOP_MID, 0 , 5 );
446423 lv_obj_align (labelMinutes, timeContainer, LV_ALIGN_IN_BOTTOM_MID, 0 , 0 );
447424 }
448425
449- if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
426+ currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get ());
427+ if (currentDate.IsUpdated ()) {
428+ uint8_t day = dateTimeController.Day ();
450429 lv_label_set_text_fmt (labelDate, " %s %02d" , dateTimeController.DayOfWeekShortToStringLow (), day);
451430 lv_obj_realign (labelDate);
452-
453- currentYear = year;
454- currentMonth = month;
455- currentDayOfWeek = dayOfWeek;
456- currentDay = day;
457431 }
458432 }
459433
0 commit comments