WatchFaceInfineat: Simplify time update check
This commit is contained in:
parent
c5c3e81e15
commit
8d089b1429
|
@ -397,63 +397,37 @@ void WatchFaceInfineat::Refresh() {
|
|||
lv_obj_align(notificationIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
char minutesChar[3];
|
||||
sprintf(minutesChar, "%02d", static_cast<int>(minute));
|
||||
|
||||
char hoursChar[3];
|
||||
char ampmChar[3];
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
if (hour < 12) {
|
||||
char ampmChar[3] = "AM";
|
||||
if (hour == 0) {
|
||||
hour = 12;
|
||||
}
|
||||
sprintf(ampmChar, "AM");
|
||||
} else { // hour >= 12
|
||||
if (hour != 12) {
|
||||
} else if (hour == 12) {
|
||||
ampmChar[0] = 'P';
|
||||
} else if (hour > 12) {
|
||||
hour = hour - 12;
|
||||
ampmChar[0] = 'P';
|
||||
}
|
||||
sprintf(ampmChar, "PM");
|
||||
}
|
||||
}
|
||||
sprintf(hoursChar, "%02d", hour);
|
||||
|
||||
if ((hoursChar[0] != displayedChar[0]) || (hoursChar[1] != displayedChar[1]) || (minutesChar[0] != displayedChar[2]) ||
|
||||
(minutesChar[1] != displayedChar[3])) {
|
||||
displayedChar[0] = hoursChar[0];
|
||||
displayedChar[1] = hoursChar[1];
|
||||
displayedChar[2] = minutesChar[0];
|
||||
displayedChar[3] = minutesChar[1];
|
||||
|
||||
lv_label_set_text_fmt(labelHour, "%s", hoursChar);
|
||||
lv_label_set_text_fmt(labelMinutes, "%s", minutesChar);
|
||||
lv_label_set_text(labelTimeAmPm, ampmChar);
|
||||
}
|
||||
lv_label_set_text_fmt(labelHour, "%02d", hour);
|
||||
lv_label_set_text_fmt(labelMinutes, "%02d", minute);
|
||||
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
lv_label_set_text(labelTimeAmPm, ampmChar);
|
||||
lv_obj_align(labelTimeAmPm, timeContainer, LV_ALIGN_OUT_RIGHT_TOP, 0, 10);
|
||||
lv_obj_align(labelHour, timeContainer, LV_ALIGN_IN_TOP_MID, 0, 5);
|
||||
lv_obj_align(labelMinutes, timeContainer, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
}
|
||||
|
||||
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
|
||||
currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
|
||||
if (currentDate.IsUpdated()) {
|
||||
uint8_t day = dateTimeController.Day();
|
||||
lv_label_set_text_fmt(labelDate, "%s %02d", dateTimeController.DayOfWeekShortToStringLow(), day);
|
||||
lv_obj_realign(labelDate);
|
||||
|
||||
currentYear = year;
|
||||
currentMonth = month;
|
||||
currentDayOfWeek = dayOfWeek;
|
||||
currentDay = day;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,12 +43,6 @@ namespace Pinetime {
|
|||
static bool IsAvailable(Pinetime::Controllers::FS& filesystem);
|
||||
|
||||
private:
|
||||
char displayedChar[5] {};
|
||||
|
||||
uint16_t currentYear = 1970;
|
||||
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
|
||||
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
|
||||
uint8_t currentDay = 0;
|
||||
uint32_t savedTick = 0;
|
||||
uint8_t chargingBatteryPercent = 101; // not a mistake ;)
|
||||
|
||||
|
@ -56,10 +50,12 @@ namespace Pinetime {
|
|||
Utility::DirtyValue<bool> isCharging {};
|
||||
Utility::DirtyValue<bool> bleState {};
|
||||
Utility::DirtyValue<bool> bleRadioEnabled {};
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::minutes>> currentDateTime {};
|
||||
Utility::DirtyValue<bool> motionSensorOk {};
|
||||
Utility::DirtyValue<uint32_t> stepCount {};
|
||||
Utility::DirtyValue<bool> notificationState {};
|
||||
using days = std::chrono::duration<int32_t, std::ratio<86400>>; // TODO: days is standard in c++20
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, days>> currentDate;
|
||||
|
||||
// Lines making up the side cover
|
||||
lv_obj_t* lineBattery;
|
||||
|
|
Loading…
Reference in New Issue
Block a user