aboutsummaryrefslogtreecommitdiffstats
path: root/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp
diff options
context:
space:
mode:
authorRiku Isokoski <riksu9000@gmail.com>2023-03-03 13:14:17 +0200
committerRiku Isokoski <riksu9000@gmail.com>2023-04-02 18:14:42 +0000
commitd251a47828171ef4001008316860a4c6f5835cc0 (patch)
treeaa41707d7473ba14d18e4586c177654b90591d18 /src/displayapp/screens/WatchFaceCasioStyleG7710.cpp
parent8d089b1429e2d448debc2d3e5149895eafe31fd8 (diff)
WatchFaceG7710: Simplify time update check
Diffstat (limited to 'src/displayapp/screens/WatchFaceCasioStyleG7710.cpp')
-rw-r--r--src/displayapp/screens/WatchFaceCasioStyleG7710.cpp62
1 files changed, 25 insertions, 37 deletions
diff --git a/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp b/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp
index ca37c8fc..a34431a4 100644
--- a/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp
+++ b/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp
@@ -222,43 +222,36 @@ void WatchFaceCasioStyleG7710::Refresh() {
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
}
- currentDateTime = dateTimeController.CurrentDateTime();
-
+ currentDateTime = std::chrono::time_point_cast<std::chrono::minutes>(dateTimeController.CurrentDateTime());
if (currentDateTime.IsUpdated()) {
- auto hour = dateTimeController.Hours();
- auto minute = dateTimeController.Minutes();
- auto year = dateTimeController.Year();
- auto month = dateTimeController.Month();
- auto dayOfWeek = dateTimeController.DayOfWeek();
- auto day = dateTimeController.Day();
- auto dayOfYear = dateTimeController.DayOfYear();
-
- auto weekNumberFormat = "%V";
+ uint8_t hour = dateTimeController.Hours();
+ uint8_t minute = dateTimeController.Minutes();
- if (displayedHour != hour || displayedMinute != minute) {
- displayedHour = hour;
- displayedMinute = minute;
-
- if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
- char ampmChar[2] = "A";
- if (hour == 0) {
- hour = 12;
- } else if (hour == 12) {
- ampmChar[0] = 'P';
- } else if (hour > 12) {
- hour = hour - 12;
- ampmChar[0] = 'P';
- }
- lv_label_set_text(label_time_ampm, ampmChar);
- lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute);
- lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 40);
- } else {
- lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute);
- lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 40);
+ if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ char ampmChar[2] = "A";
+ if (hour == 0) {
+ hour = 12;
+ } else if (hour == 12) {
+ ampmChar[0] = 'P';
+ } else if (hour > 12) {
+ hour = hour - 12;
+ ampmChar[0] = 'P';
}
+ lv_label_set_text(label_time_ampm, ampmChar);
+ lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute);
+ } else {
+ lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute);
}
+ lv_obj_realign(label_time);
+
+ currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
+ if (currentDate.IsUpdated()) {
+ const char* weekNumberFormat = "%V";
- if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
+ uint16_t year = dateTimeController.Year();
+ Controllers::DateTime::Months month = dateTimeController.Month();
+ uint8_t day = dateTimeController.Day();
+ int dayOfYear = dateTimeController.DayOfYear();
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
// 24h mode: ddmmyyyy, first DOW=Monday;
lv_label_set_text_fmt(label_date, "%3d-%2d", day, month);
@@ -293,11 +286,6 @@ void WatchFaceCasioStyleG7710::Refresh() {
lv_obj_realign(label_day_of_year);
lv_obj_realign(label_week_number);
lv_obj_realign(label_date);
-
- currentYear = year;
- currentMonth = month;
- currentDayOfWeek = dayOfWeek;
- currentDay = day;
}
}