Skip to content

Commit 11ade64

Browse files
committed
WatchFaceAnalog: Simplify date update check
1 parent e55a76f commit 11ade64

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/displayapp/screens/WatchFaceAnalog.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,12 @@ void WatchFaceAnalog::Refresh() {
223223
}
224224

225225
currentDateTime = dateTimeController.CurrentDateTime();
226-
227226
if (currentDateTime.IsUpdated()) {
228-
Pinetime::Controllers::DateTime::Months month = dateTimeController.Month();
229-
uint8_t day = dateTimeController.Day();
230-
Pinetime::Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek();
231-
232227
UpdateClock();
233228

234-
if ((month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
235-
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), day);
236-
237-
currentMonth = month;
238-
currentDayOfWeek = dayOfWeek;
239-
currentDay = day;
229+
currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
230+
if (currentDate.IsUpdated()) {
231+
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
240232
}
241233
}
242234
}

src/displayapp/screens/WatchFaceAnalog.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,13 @@ namespace Pinetime {
3737
private:
3838
uint8_t sHour, sMinute, sSecond;
3939

40-
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
41-
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
42-
uint8_t currentDay = 0;
43-
4440
DirtyValue<uint8_t> batteryPercentRemaining {0};
4541
DirtyValue<bool> isCharging {};
4642
DirtyValue<bool> bleState {};
4743
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
4844
DirtyValue<bool> notificationState {false};
45+
using days = std::chrono::duration<int32_t, std::ratio<86400>>; // TODO: days is standard in c++20
46+
DirtyValue<std::chrono::time_point<std::chrono::system_clock, days>> currentDate;
4947

5048
lv_obj_t* hour_body;
5149
lv_obj_t* hour_body_trace;

0 commit comments

Comments
 (0)