1
0
Fork 0

WatchFaceAnalog: Simplify date update check

This commit is contained in:
Riku Isokoski 2023-03-03 12:20:18 +02:00
parent e55a76f740
commit 11ade64166
2 changed files with 5 additions and 15 deletions

View file

@ -223,20 +223,12 @@ void WatchFaceAnalog::Refresh() {
} }
currentDateTime = dateTimeController.CurrentDateTime(); currentDateTime = dateTimeController.CurrentDateTime();
if (currentDateTime.IsUpdated()) { if (currentDateTime.IsUpdated()) {
Pinetime::Controllers::DateTime::Months month = dateTimeController.Month();
uint8_t day = dateTimeController.Day();
Pinetime::Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek();
UpdateClock(); UpdateClock();
if ((month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) { currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), day); if (currentDate.IsUpdated()) {
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
currentMonth = month;
currentDayOfWeek = dayOfWeek;
currentDay = day;
} }
} }
} }

View file

@ -37,15 +37,13 @@ namespace Pinetime {
private: private:
uint8_t sHour, sMinute, sSecond; uint8_t sHour, sMinute, sSecond;
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0;
DirtyValue<uint8_t> batteryPercentRemaining {0}; DirtyValue<uint8_t> batteryPercentRemaining {0};
DirtyValue<bool> isCharging {}; DirtyValue<bool> isCharging {};
DirtyValue<bool> bleState {}; DirtyValue<bool> bleState {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime; DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
DirtyValue<bool> notificationState {false}; DirtyValue<bool> notificationState {false};
using days = std::chrono::duration<int32_t, std::ratio<86400>>; // TODO: days is standard in c++20
DirtyValue<std::chrono::time_point<std::chrono::system_clock, days>> currentDate;
lv_obj_t* hour_body; lv_obj_t* hour_body;
lv_obj_t* hour_body_trace; lv_obj_t* hour_body_trace;