From 58b358ef9501508abf80d21bf87fd12e616a6643 Mon Sep 17 00:00:00 2001 From: uli Date: Thu, 2 Jun 2022 12:30:19 +0200 Subject: [PATCH] Revert "Add Setting to display UTC. Change Clockfaces to actually do it" This reverts commit ed346fc465ce3e91f03ac09dabb8afd55423633a. --- src/components/settings/Settings.h | 2 +- src/displayapp/screens/WatchFaceAnalog.cpp | 54 ++++++++----------- src/displayapp/screens/WatchFaceDigital.cpp | 22 +++----- .../screens/WatchFacePineTimeStyle.cpp | 5 -- src/displayapp/screens/WatchFaceTerminal.cpp | 39 ++++++-------- .../screens/settings/SettingTimeFormat.cpp | 21 +++----- .../screens/settings/SettingTimeFormat.h | 2 +- 7 files changed, 53 insertions(+), 92 deletions(-) diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 55ab95ed..3b113ead 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -8,7 +8,7 @@ namespace Pinetime { namespace Controllers { class Settings { public: - enum class ClockType : uint8_t { H24, H12, UTC }; + enum class ClockType : uint8_t { H24, H12 }; enum class Notification : uint8_t { ON, OFF }; enum class ChimesOption : uint8_t { None, Hours, HalfHours }; enum class WakeUpMode : uint8_t { diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 39111fb1..dd5b2929 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -1,6 +1,5 @@ #include "displayapp/screens/WatchFaceAnalog.h" #include -#include #include #include "displayapp/screens/BatteryIcon.h" #include "displayapp/screens/BleIcon.h" @@ -13,33 +12,35 @@ LV_IMG_DECLARE(bg_clock); using namespace Pinetime::Applications::Screens; namespace { - constexpr int16_t HourLength = 70; - constexpr int16_t MinuteLength = 90; - constexpr int16_t SecondLength = 110; +constexpr int16_t HourLength = 70; +constexpr int16_t MinuteLength = 90; +constexpr int16_t SecondLength = 110; - // sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor - const auto LV_TRIG_SCALE = _lv_trigo_sin(90); +// sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor +const auto LV_TRIG_SCALE = _lv_trigo_sin(90); - int16_t Cosine(int16_t angle) { - return _lv_trigo_sin(angle + 90); - } +int16_t Cosine(int16_t angle) { + return _lv_trigo_sin(angle + 90); +} - int16_t Sine(int16_t angle) { - return _lv_trigo_sin(angle); - } +int16_t Sine(int16_t angle) { + return _lv_trigo_sin(angle); +} - int16_t CoordinateXRelocate(int16_t x) { - return (x + LV_HOR_RES / 2); - } +int16_t CoordinateXRelocate(int16_t x) { + return (x + LV_HOR_RES / 2); +} - int16_t CoordinateYRelocate(int16_t y) { - return std::abs(y - LV_HOR_RES / 2); - } +int16_t CoordinateYRelocate(int16_t y) { + return std::abs(y - LV_HOR_RES / 2); +} - lv_point_t CoordinateRelocate(int16_t radius, int16_t angle) { - return lv_point_t {.x = CoordinateXRelocate(radius * static_cast(Sine(angle)) / LV_TRIG_SCALE), - .y = CoordinateYRelocate(radius * static_cast(Cosine(angle)) / LV_TRIG_SCALE)}; - } +lv_point_t CoordinateRelocate(int16_t radius, int16_t angle) { + return lv_point_t{ + .x = CoordinateXRelocate(radius * static_cast(Sine(angle)) / LV_TRIG_SCALE), + .y = CoordinateYRelocate(radius * static_cast(Cosine(angle)) / LV_TRIG_SCALE) + }; +} } @@ -144,15 +145,6 @@ void WatchFaceAnalog::UpdateClock() { uint8_t minute = dateTimeController.Minutes(); uint8_t second = dateTimeController.Seconds(); - if (settingsController.GetClockType() == Controllers::Settings::ClockType::UTC) { - auto utcDateTime = dateTimeController.UTCDateTime(); - auto dp = date::floor(utcDateTime); - auto time = date::make_time(utcDateTime - dp); - hour = time.hours().count(); - minute = time.minutes().count(); - second = time.seconds().count(); - } - if (sMinute != minute) { auto const angle = minute * 6; minute_point[0] = CoordinateRelocate(30, angle); diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 1ff6a677..1df38255 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -120,10 +120,6 @@ void WatchFaceDigital::Refresh() { currentDateTime = dateTimeController.CurrentDateTime(); - if (settingsController.GetClockType() == Controllers::Settings::ClockType::UTC) { - currentDateTime = dateTimeController.UTCDateTime(); - } - if (currentDateTime.IsUpdated()) { auto newDateTime = currentDateTime.Get(); @@ -163,18 +159,12 @@ void WatchFaceDigital::Refresh() { } if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) { - switch (settingsController.GetClockType()) { - default: - case Controllers::Settings::ClockType::H24: - lv_label_set_text_fmt( - label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year); - break; - case Controllers::Settings::ClockType::H12: - lv_label_set_text_fmt( - label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year); - case Controllers::Settings::ClockType::UTC: - lv_label_set_text_fmt(label_date, "%d-%d-%d", year, static_cast(month), day); - break; + if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) { + lv_label_set_text_fmt( + label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year); + } else { + lv_label_set_text_fmt( + label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year); } lv_obj_realign(label_date); diff --git a/src/displayapp/screens/WatchFacePineTimeStyle.cpp b/src/displayapp/screens/WatchFacePineTimeStyle.cpp index 9e22d654..dad2f4c7 100644 --- a/src/displayapp/screens/WatchFacePineTimeStyle.cpp +++ b/src/displayapp/screens/WatchFacePineTimeStyle.cpp @@ -383,11 +383,6 @@ void WatchFacePineTimeStyle::Refresh() { } currentDateTime = dateTimeController.CurrentDateTime(); - - if (settingsController.GetClockType() == Controllers::Settings::ClockType::UTC) { - currentDateTime = dateTimeController.UTCDateTime(); - } - if (currentDateTime.IsUpdated()) { auto newDateTime = currentDateTime.Get(); diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp index 143694c1..80d736cf 100644 --- a/src/displayapp/screens/WatchFaceTerminal.cpp +++ b/src/displayapp/screens/WatchFaceTerminal.cpp @@ -89,7 +89,7 @@ void WatchFaceTerminal::Refresh() { bleState = bleController.IsConnected(); bleRadioEnabled = bleController.IsRadioEnabled(); if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) { - if (!bleRadioEnabled.Get()) { + if(!bleRadioEnabled.Get()) { lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#"); } else { if (bleState.Get()) { @@ -111,10 +111,6 @@ void WatchFaceTerminal::Refresh() { currentDateTime = dateTimeController.CurrentDateTime(); - if (settingsController.GetClockType() == Controllers::Settings::ClockType::UTC) { - currentDateTime = dateTimeController.UTCDateTime(); - } - if (currentDateTime.IsUpdated()) { auto newDateTime = currentDateTime.Get(); @@ -136,29 +132,24 @@ void WatchFaceTerminal::Refresh() { displayedMinute = minute; displayedSecond = second; - switch (settingsController.GetClockType()) { - case Controllers::Settings::ClockType::H12: { - char ampmChar[3] = "AM"; - 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_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar); - } break; - case Controllers::Settings::ClockType::H24: - lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second); - break; - case Controllers::Settings::ClockType::UTC: - lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02dZ", hour, minute, second); + if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { + char ampmChar[3] = "AM"; + 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_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar); + } else { + lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second); } } if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) { - lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d-%02d-%02d#", short(year), char(month), char(day)); + lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d.%02d.%02d#", short(year), char(month), char(day)); currentYear = year; currentMonth = month; diff --git a/src/displayapp/screens/settings/SettingTimeFormat.cpp b/src/displayapp/screens/settings/SettingTimeFormat.cpp index f7da3f46..5502794b 100644 --- a/src/displayapp/screens/settings/SettingTimeFormat.cpp +++ b/src/displayapp/screens/settings/SettingTimeFormat.cpp @@ -14,7 +14,7 @@ namespace { } } -constexpr std::array SettingTimeFormat::options; +constexpr std::array SettingTimeFormat::options; SettingTimeFormat::SettingTimeFormat(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) : Screen(app), settingsController {settingsController} { @@ -54,8 +54,6 @@ SettingTimeFormat::SettingTimeFormat(Pinetime::Applications::DisplayApp* app, Pi lv_checkbox_set_checked(cbOption[0], true); } else if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) { lv_checkbox_set_checked(cbOption[1], true); - } else if (settingsController.GetClockType() == Controllers::Settings::ClockType::UTC) { - lv_checkbox_set_checked(cbOption[2], true); } } @@ -70,17 +68,12 @@ void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) { if (object == cbOption[i]) { lv_checkbox_set_checked(cbOption[i], true); - switch (i) { - case 0: - settingsController.SetClockType(Controllers::Settings::ClockType::H12); - break; - case 1: - settingsController.SetClockType(Controllers::Settings::ClockType::H24); - break; - case 2: - settingsController.SetClockType(Controllers::Settings::ClockType::UTC); - break; - } + if (i == 0) { + settingsController.SetClockType(Controllers::Settings::ClockType::H12); + }; + if (i == 1) { + settingsController.SetClockType(Controllers::Settings::ClockType::H24); + }; } else { lv_checkbox_set_checked(cbOption[i], false); diff --git a/src/displayapp/screens/settings/SettingTimeFormat.h b/src/displayapp/screens/settings/SettingTimeFormat.h index 04f5ef00..818edf0c 100644 --- a/src/displayapp/screens/settings/SettingTimeFormat.h +++ b/src/displayapp/screens/settings/SettingTimeFormat.h @@ -20,7 +20,7 @@ namespace Pinetime { void UpdateSelected(lv_obj_t* object, lv_event_t event); private: - static constexpr std::array options = {" 12-hour", " 24-hour", " UTC"}; + static constexpr std::array options = {" 12-hour", " 24-hour"}; Controllers::Settings& settingsController; lv_obj_t* cbOption[options.size()]; };