From ea44d8f0ac244711e98c1bc9139fc0257dc9bb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aaron=20Z=C3=BCger?= Date: Wed, 8 Nov 2023 03:39:53 +0100 Subject: [PATCH 1/6] add 24 hour clock watch face: SlowTime --- src/CMakeLists.txt | 1 + src/displayapp/WatchFaces.h | 5 +- src/displayapp/screens/Clock.cpp | 12 + src/displayapp/screens/Clock.h | 1 + src/displayapp/screens/WatchFaceSlowTime.cpp | 286 ++++++++++++++++++ src/displayapp/screens/WatchFaceSlowTime.h | 94 ++++++ .../screens/settings/SettingWatchFace.h | 3 +- 7 files changed, 399 insertions(+), 3 deletions(-) create mode 100644 src/displayapp/screens/WatchFaceSlowTime.cpp create mode 100644 src/displayapp/screens/WatchFaceSlowTime.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8e8e96863b..9496863cd6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -433,6 +433,7 @@ list(APPEND SOURCE_FILES displayapp/screens/WatchFaceTerminal.cpp displayapp/screens/WatchFacePineTimeStyle.cpp displayapp/screens/WatchFaceCasioStyleG7710.cpp + displayapp/screens/WatchFaceSlowTime.cpp ## diff --git a/src/displayapp/WatchFaces.h b/src/displayapp/WatchFaces.h index 2982347aa1..f24353ea28 100644 --- a/src/displayapp/WatchFaces.h +++ b/src/displayapp/WatchFaces.h @@ -7,8 +7,9 @@ namespace Pinetime { Analog = 1, PineTimeStyle = 2, Terminal = 3, - Infineat = 4, - CasioStyleG7710 = 5, + SlowTime = 4, + Infineat = 5, + CasioStyleG7710 = 6, }; } } diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index 4219b090db..7581bc25f2 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -13,6 +13,7 @@ #include "displayapp/screens/WatchFaceAnalog.h" #include "displayapp/screens/WatchFacePineTimeStyle.h" #include "displayapp/screens/WatchFaceCasioStyleG7710.h" +#include "displayapp/screens/WatchFaceSlowTime.h" using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications; @@ -55,6 +56,9 @@ Clock::Clock(Controllers::DateTime& dateTimeController, case WatchFace::CasioStyleG7710: return WatchFaceCasioStyleG7710(); break; + case WatchFace::SlowTime: + return WatchFaceSlowTimeScreen(); + break; } return WatchFaceDigitalScreen(); }()} { @@ -131,3 +135,11 @@ std::unique_ptr Clock::WatchFaceCasioStyleG7710() { motionController, filesystem); } + +std::unique_ptr Clock::WatchFaceSlowTimeScreen() { + return std::make_unique(dateTimeController, + batteryController, + bleController, + notificationManager, + settingsController); +} diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h index f3591f43c6..a20d04b6f4 100644 --- a/src/displayapp/screens/Clock.h +++ b/src/displayapp/screens/Clock.h @@ -54,6 +54,7 @@ namespace Pinetime { std::unique_ptr WatchFaceTerminalScreen(); std::unique_ptr WatchFaceInfineatScreen(); std::unique_ptr WatchFaceCasioStyleG7710(); + std::unique_ptr WatchFaceSlowTimeScreen(); }; } } diff --git a/src/displayapp/screens/WatchFaceSlowTime.cpp b/src/displayapp/screens/WatchFaceSlowTime.cpp new file mode 100644 index 0000000000..0ecbc79bd7 --- /dev/null +++ b/src/displayapp/screens/WatchFaceSlowTime.cpp @@ -0,0 +1,286 @@ +#include "displayapp/screens/WatchFaceSlowTime.h" +#include +#include +#include "displayapp/screens/BatteryIcon.h" +#include "displayapp/screens/BleIcon.h" +#include "displayapp/screens/Symbols.h" +#include "displayapp/screens/NotificationIcon.h" +#include "components/settings/Settings.h" +#include "displayapp/InfiniTimeTheme.h" + +using namespace Pinetime::Applications::Screens; + +namespace { + constexpr int16_t HourLength = 50; + constexpr int16_t MinuteLength = 80; + + // 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 Sine(int16_t angle) { + return _lv_trigo_sin(angle); + } + + 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); + } + + 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)}; + } + +} + +WatchFaceSlowTime::WatchFaceSlowTime(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController) + : currentDateTime {{}}, + batteryIcon(true), + dateTimeController {dateTimeController}, + batteryController {batteryController}, + bleController {bleController}, + notificationManager {notificationManager}, + settingsController {settingsController} { + + sHour = 99; + sMinute = 99; + + minor_scales = lv_linemeter_create(lv_scr_act(), nullptr); + lv_linemeter_set_scale(minor_scales, 360, 61); + lv_linemeter_set_angle_offset(minor_scales, 180); + lv_obj_set_size(minor_scales, 240, 240); + lv_obj_align(minor_scales, nullptr, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_style_local_bg_opa(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); + lv_obj_set_style_local_scale_width(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); + lv_obj_set_style_local_scale_end_line_width(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 1); + lv_obj_set_style_local_scale_end_color(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + + major_scales= lv_linemeter_create(lv_scr_act(), nullptr); + lv_linemeter_set_scale(major_scales, 360, 13); + lv_linemeter_set_angle_offset(major_scales, 30); + lv_obj_set_size(major_scales, 240, 240); + lv_obj_align(major_scales, nullptr, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_style_local_bg_opa(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); + lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); + lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 2); + lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + + large_scales= lv_linemeter_create(lv_scr_act(), nullptr); + lv_linemeter_set_scale(large_scales, 360, 13); + lv_linemeter_set_angle_offset(large_scales, 15); + lv_obj_set_size(large_scales, 220, 220); + lv_obj_align(large_scales, nullptr, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_style_local_bg_opa(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); + lv_obj_set_style_local_scale_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 10); + lv_obj_set_style_local_scale_end_line_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 3); + lv_obj_set_style_local_scale_end_color(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + two = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(two, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(two, "2"); + lv_obj_set_pos(two, 160, 30); + lv_obj_set_style_local_text_color(two, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + four = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(four, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(four, "4"); + lv_obj_set_pos(four, 192, 60); + lv_obj_set_style_local_text_color(four, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + six = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(six, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(six, "6"); + lv_obj_set_pos(six, 206, 107); + lv_obj_set_style_local_text_color(six, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + eight = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(eight, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(eight, "8"); + lv_obj_set_pos(eight, 192, 154); + lv_obj_set_style_local_text_color(eight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + ten = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(ten, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(ten, "10"); + lv_obj_set_pos(ten, 153, 184); + lv_obj_set_style_local_text_color(ten, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + twelve = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(twelve, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(twelve, "12"); + lv_obj_set_pos(twelve, 107, 198); + lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + fourteen = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(fourteen, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(fourteen, "14"); + lv_obj_set_pos(fourteen, 62, 184); + lv_obj_set_style_local_text_color(fourteen, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + sixteen = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(sixteen, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(sixteen, "16"); + lv_obj_set_pos(sixteen, 32, 152); + lv_obj_set_style_local_text_color(sixteen, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + eighteen = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(eighteen, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(eighteen, "18"); + lv_obj_set_pos(eighteen, 20, 107); + lv_obj_set_style_local_text_color(eighteen, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + twenty = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(twenty, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(twenty, "20"); + lv_obj_set_pos(twenty, 32, 62); + lv_obj_set_style_local_text_color(twenty, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + twentytwo = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(twentytwo, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(twentytwo, "22"); + lv_obj_set_pos(twentytwo, 62, 30); + lv_obj_set_style_local_text_color(twentytwo, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + twentyfour = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(twentyfour, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(twentyfour, "24"); + lv_obj_set_pos(twentyfour, 107, 17); + lv_obj_set_style_local_text_color(twentyfour, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + batteryIcon.Create(lv_scr_act()); + lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0); + + plugIcon = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_text_static(plugIcon, Symbols::plug); + lv_obj_align(plugIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0); + + bleIcon = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_text_static(bleIcon, ""); + lv_obj_align(bleIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, -30, 0); + + notificationIcon = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_LIME); + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); + lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); + + // Date - Day / Week day + + label_date_day = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAROON); + lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); + lv_label_set_align(label_date_day, LV_LABEL_ALIGN_CENTER); + lv_obj_align(label_date_day, nullptr, LV_ALIGN_CENTER, 50, 0); + + minute_body = lv_line_create(lv_scr_act(), nullptr); + hour_body = lv_line_create(lv_scr_act(), nullptr); + + lv_style_init(&minute_line_style); + lv_style_set_line_width(&minute_line_style, LV_STATE_DEFAULT, 3); + lv_style_set_line_color(&minute_line_style, LV_STATE_DEFAULT, LV_COLOR_TEAL); + lv_style_set_line_rounded(&minute_line_style, LV_STATE_DEFAULT, true); + lv_obj_add_style(minute_body, LV_LINE_PART_MAIN, &minute_line_style); + + lv_style_init(&hour_line_style); + lv_style_set_line_width(&hour_line_style, LV_STATE_DEFAULT, 5); + lv_style_set_line_color(&hour_line_style, LV_STATE_DEFAULT, LV_COLOR_TEAL); + lv_style_set_line_rounded(&hour_line_style, LV_STATE_DEFAULT, true); + lv_obj_add_style(hour_body, LV_LINE_PART_MAIN, &hour_line_style); + + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + + Refresh(); +} + +WatchFaceSlowTime::~WatchFaceSlowTime() { + lv_task_del(taskRefresh); + + lv_style_reset(&hour_line_style); + lv_style_reset(&minute_line_style); + + lv_obj_clean(lv_scr_act()); +} + +void WatchFaceSlowTime::UpdateClock() { + uint8_t hour = dateTimeController.Hours(); + uint8_t minute = dateTimeController.Minutes(); + + if (sMinute != minute) { + auto const angle = minute * 6; + minute_point[0] = CoordinateRelocate(-15, angle); + minute_point[1] = CoordinateRelocate(MinuteLength, angle); + + lv_line_set_points(minute_body, minute_point, 2); + } + + if (sHour != hour || sMinute != minute) { + sHour = hour; + sMinute = minute; + auto const angle = (hour * 15 + minute / 4); + + hour_point[0] = CoordinateRelocate(-15, angle); + hour_point[1] = CoordinateRelocate(HourLength, angle); + + lv_line_set_points(hour_body, hour_point, 2); + } +} + +void WatchFaceSlowTime::SetBatteryIcon() { + auto batteryPercent = batteryPercentRemaining.Get(); + batteryIcon.SetBatteryPercentage(batteryPercent); +} + +void WatchFaceSlowTime::Refresh() { + isCharging = batteryController.IsCharging(); + if (isCharging.IsUpdated()) { + if (isCharging.Get()) { + lv_obj_set_hidden(batteryIcon.GetObject(), true); + lv_obj_set_hidden(plugIcon, false); + } else { + lv_obj_set_hidden(batteryIcon.GetObject(), false); + lv_obj_set_hidden(plugIcon, true); + SetBatteryIcon(); + } + } + if (!isCharging.Get()) { + batteryPercentRemaining = batteryController.PercentRemaining(); + if (batteryPercentRemaining.IsUpdated()) { + SetBatteryIcon(); + } + } + + bleState = bleController.IsConnected(); + if (bleState.IsUpdated()) { + if (bleState.Get()) { + lv_label_set_text_static(bleIcon, Symbols::bluetooth); + } else { + lv_label_set_text_static(bleIcon, ""); + } + } + + notificationState = notificationManager.AreNewNotificationsAvailable(); + + if (notificationState.IsUpdated()) { + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); + } + + currentDateTime = dateTimeController.CurrentDateTime(); + if (currentDateTime.IsUpdated()) { + UpdateClock(); + + currentDate = std::chrono::time_point_cast(currentDateTime.Get()); + if (currentDate.IsUpdated()) { + lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); + } + } +} diff --git a/src/displayapp/screens/WatchFaceSlowTime.h b/src/displayapp/screens/WatchFaceSlowTime.h new file mode 100644 index 0000000000..e8e24c4e0a --- /dev/null +++ b/src/displayapp/screens/WatchFaceSlowTime.h @@ -0,0 +1,94 @@ +#pragma once + +#include +#include +#include +#include +#include "displayapp/screens/Screen.h" +#include "components/datetime/DateTimeController.h" +#include "components/battery/BatteryController.h" +#include "components/ble/BleController.h" +#include "components/ble/NotificationManager.h" +#include "displayapp/screens/BatteryIcon.h" +#include "utility/DirtyValue.h" + +namespace Pinetime { + namespace Controllers { + class Settings; + class Battery; + class Ble; + class NotificationManager; + } + + namespace Applications { + namespace Screens { + + class WatchFaceSlowTime : public Screen { + public: + WatchFaceSlowTime(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController); + + ~WatchFaceSlowTime() override; + + void Refresh() override; + + private: + uint8_t sHour, sMinute; + + Utility::DirtyValue batteryPercentRemaining {0}; + Utility::DirtyValue isCharging {}; + Utility::DirtyValue bleState {}; + Utility::DirtyValue> currentDateTime; + Utility::DirtyValue notificationState {false}; + using days = std::chrono::duration>; // TODO: days is standard in c++20 + Utility::DirtyValue> currentDate; + + lv_obj_t* minor_scales; + lv_obj_t* major_scales; + lv_obj_t* large_scales; + lv_obj_t* two; + lv_obj_t* four; + lv_obj_t* six; + lv_obj_t* eight; + lv_obj_t* ten; + lv_obj_t* twelve; + lv_obj_t* fourteen; + lv_obj_t* sixteen; + lv_obj_t* eighteen; + lv_obj_t* twenty; + lv_obj_t* twentytwo; + lv_obj_t* twentyfour; + + lv_obj_t* hour_body; + lv_obj_t* minute_body; + + lv_point_t hour_point[2]; + lv_point_t minute_point[2]; + + lv_style_t hour_line_style; + lv_style_t minute_line_style; + + lv_obj_t* label_date_day; + lv_obj_t* plugIcon; + lv_obj_t* notificationIcon; + lv_obj_t* bleIcon; + + BatteryIcon batteryIcon; + + const Controllers::DateTime& dateTimeController; + const Controllers::Battery& batteryController; + const Controllers::Ble& bleController; + Controllers::NotificationManager& notificationManager; + Controllers::Settings& settingsController; + + void UpdateClock(); + void SetBatteryIcon(); + + lv_task_t* taskRefresh; + }; + } + } +} diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h index 45a50e3d0b..a9d8a5f758 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.h +++ b/src/displayapp/screens/settings/SettingWatchFace.h @@ -11,6 +11,7 @@ #include "displayapp/screens/CheckboxList.h" #include "displayapp/screens/WatchFaceInfineat.h" #include "displayapp/screens/WatchFaceCasioStyleG7710.h" +#include "displayapp/screens/WatchFaceSlowTime.h" namespace Pinetime { @@ -45,9 +46,9 @@ namespace Pinetime { {"Analog face", true}, {"PineTimeStyle", true}, {"Terminal", true}, + {"SlowTime", true}, {"Infineat face", Applications::Screens::WatchFaceInfineat::IsAvailable(filesystem)}, {"Casio G7710", Applications::Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem)}, - {"", false}, {"", false}}}; ScreenList screens; }; From afea7c5bf186a2f9ecc9e7583b543146b9315d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aaron=20Z=C3=BCger?= Date: Thu, 23 Nov 2023 19:25:59 +0100 Subject: [PATCH 2/6] narrow down minute and hour hand --- src/displayapp/screens/WatchFaceAnalog.cpp | 48 +++++++++++----------- src/displayapp/screens/WatchFaceAnalog.h | 12 +++--- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 2b27ad6402..13859c448c 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -119,9 +119,9 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, lv_obj_align(label_date_day, nullptr, LV_ALIGN_CENTER, 50, 0); minute_body = lv_line_create(lv_scr_act(), nullptr); - minute_body_trace = lv_line_create(lv_scr_act(), nullptr); + /* minute_body_trace = lv_line_create(lv_scr_act(), nullptr); */ hour_body = lv_line_create(lv_scr_act(), nullptr); - hour_body_trace = lv_line_create(lv_scr_act(), nullptr); + /* hour_body_trace = lv_line_create(lv_scr_act(), nullptr); */ second_body = lv_line_create(lv_scr_act(), nullptr); lv_style_init(&second_line_style); @@ -131,28 +131,28 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, lv_obj_add_style(second_body, LV_LINE_PART_MAIN, &second_line_style); lv_style_init(&minute_line_style); - lv_style_set_line_width(&minute_line_style, LV_STATE_DEFAULT, 7); + lv_style_set_line_width(&minute_line_style, LV_STATE_DEFAULT, 3); lv_style_set_line_color(&minute_line_style, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_style_set_line_rounded(&minute_line_style, LV_STATE_DEFAULT, true); lv_obj_add_style(minute_body, LV_LINE_PART_MAIN, &minute_line_style); - lv_style_init(&minute_line_style_trace); - lv_style_set_line_width(&minute_line_style_trace, LV_STATE_DEFAULT, 3); - lv_style_set_line_color(&minute_line_style_trace, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_style_set_line_rounded(&minute_line_style_trace, LV_STATE_DEFAULT, false); - lv_obj_add_style(minute_body_trace, LV_LINE_PART_MAIN, &minute_line_style_trace); + /* lv_style_init(&minute_line_style_trace); */ + /* lv_style_set_line_width(&minute_line_style_trace, LV_STATE_DEFAULT, 3); */ + /* lv_style_set_line_color(&minute_line_style_trace, LV_STATE_DEFAULT, LV_COLOR_WHITE); */ + /* lv_style_set_line_rounded(&minute_line_style_trace, LV_STATE_DEFAULT, false); */ + /* lv_obj_add_style(minute_body_trace, LV_LINE_PART_MAIN, &minute_line_style_trace); */ lv_style_init(&hour_line_style); - lv_style_set_line_width(&hour_line_style, LV_STATE_DEFAULT, 7); + lv_style_set_line_width(&hour_line_style, LV_STATE_DEFAULT, 5); lv_style_set_line_color(&hour_line_style, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_style_set_line_rounded(&hour_line_style, LV_STATE_DEFAULT, true); lv_obj_add_style(hour_body, LV_LINE_PART_MAIN, &hour_line_style); - lv_style_init(&hour_line_style_trace); - lv_style_set_line_width(&hour_line_style_trace, LV_STATE_DEFAULT, 3); - lv_style_set_line_color(&hour_line_style_trace, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false); - lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace); + /* lv_style_init(&hour_line_style_trace); */ + /* lv_style_set_line_width(&hour_line_style_trace, LV_STATE_DEFAULT, 3); */ + /* lv_style_set_line_color(&hour_line_style_trace, LV_STATE_DEFAULT, LV_COLOR_WHITE); */ + /* lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false); */ + /* lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace); */ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); @@ -163,9 +163,9 @@ WatchFaceAnalog::~WatchFaceAnalog() { lv_task_del(taskRefresh); lv_style_reset(&hour_line_style); - lv_style_reset(&hour_line_style_trace); + /* lv_style_reset(&hour_line_style_trace); */ lv_style_reset(&minute_line_style); - lv_style_reset(&minute_line_style_trace); + /* lv_style_reset(&minute_line_style_trace); */ lv_style_reset(&second_line_style); lv_obj_clean(lv_scr_act()); @@ -178,14 +178,14 @@ void WatchFaceAnalog::UpdateClock() { if (sMinute != minute) { auto const angle = minute * 6; - minute_point[0] = CoordinateRelocate(30, angle); + minute_point[0] = CoordinateRelocate(-15, angle); minute_point[1] = CoordinateRelocate(MinuteLength, angle); - minute_point_trace[0] = CoordinateRelocate(5, angle); - minute_point_trace[1] = CoordinateRelocate(31, angle); + /* minute_point_trace[0] = CoordinateRelocate(5, angle); */ + /* minute_point_trace[1] = CoordinateRelocate(31, angle); */ lv_line_set_points(minute_body, minute_point, 2); - lv_line_set_points(minute_body_trace, minute_point_trace, 2); + /* lv_line_set_points(minute_body_trace, minute_point_trace, 2); */ } if (sHour != hour || sMinute != minute) { @@ -193,14 +193,14 @@ void WatchFaceAnalog::UpdateClock() { sMinute = minute; auto const angle = (hour * 30 + minute / 2); - hour_point[0] = CoordinateRelocate(30, angle); + hour_point[0] = CoordinateRelocate(-10, angle); hour_point[1] = CoordinateRelocate(HourLength, angle); - hour_point_trace[0] = CoordinateRelocate(5, angle); - hour_point_trace[1] = CoordinateRelocate(31, angle); + /* hour_point_trace[0] = CoordinateRelocate(5, angle); */ + /* hour_point_trace[1] = CoordinateRelocate(31, angle); */ lv_line_set_points(hour_body, hour_point, 2); - lv_line_set_points(hour_body_trace, hour_point_trace, 2); + /* lv_line_set_points(hour_body_trace, hour_point_trace, 2); */ } if (sSecond != second) { diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h index 7e83cfcb14..946dbc11eb 100644 --- a/src/displayapp/screens/WatchFaceAnalog.h +++ b/src/displayapp/screens/WatchFaceAnalog.h @@ -52,21 +52,21 @@ namespace Pinetime { lv_obj_t* twelve; lv_obj_t* hour_body; - lv_obj_t* hour_body_trace; + /* lv_obj_t* hour_body_trace; */ lv_obj_t* minute_body; - lv_obj_t* minute_body_trace; + /* lv_obj_t* minute_body_trace; */ lv_obj_t* second_body; lv_point_t hour_point[2]; - lv_point_t hour_point_trace[2]; + /* lv_point_t hour_point_trace[2]; */ lv_point_t minute_point[2]; - lv_point_t minute_point_trace[2]; + /* lv_point_t minute_point_trace[2]; */ lv_point_t second_point[2]; lv_style_t hour_line_style; - lv_style_t hour_line_style_trace; + /* lv_style_t hour_line_style_trace; */ lv_style_t minute_line_style; - lv_style_t minute_line_style_trace; + /* lv_style_t minute_line_style_trace; */ lv_style_t second_line_style; lv_obj_t* label_date_day; From 73a56803b73cd17c5fa2fa6f02e992584633adce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aaron=20Z=C3=BCger?= Date: Thu, 23 Nov 2023 20:50:00 +0100 Subject: [PATCH 3/6] add menu buttons and settings for toggling 24 hour mode as well as display of the second hand --- src/components/settings/Settings.h | 28 +++++ src/displayapp/screens/WatchFaceAnalog.cpp | 116 ++++++++++++++++++++- src/displayapp/screens/WatchFaceAnalog.h | 11 ++ 3 files changed, 154 insertions(+), 1 deletion(-) diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 81cf492332..7d32be053d 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -35,6 +35,8 @@ namespace Pinetime { }; enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric }; enum class PTSWeather : uint8_t { On, Off }; + enum class A24HourMode : uint8_t { On, Off }; + enum class ASecondHand : uint8_t { On, Off }; struct PineTimeStyle { Colors ColorTime = Colors::Teal; @@ -44,6 +46,11 @@ namespace Pinetime { PTSWeather weatherEnable = PTSWeather::Off; }; + struct Analog { + A24HourMode tfHourEnable = A24HourMode::Off; + ASecondHand secondHandEnable = ASecondHand::On; + }; + struct WatchFaceInfineat { bool showSideCover = true; int colorIndex = 0; @@ -153,6 +160,26 @@ namespace Pinetime { return settings.PTS.weatherEnable; }; + void SetA24HourMode(A24HourMode tfHourEnable) { + if (tfHourEnable != settings.A.tfHourEnable) + settingsChanged = true; + settings.A.tfHourEnable = tfHourEnable; + }; + + A24HourMode GetA24HourMode() const { + return settings.A.tfHourEnable; + }; + + void SetASecondHand(ASecondHand secondHandEnable) { + if (secondHandEnable != settings.A.secondHandEnable) + settingsChanged = true; + settings.A.secondHandEnable = secondHandEnable; + }; + + ASecondHand GetASecondHand() const { + return settings.A.secondHandEnable; + }; + void SetAppMenu(uint8_t menu) { appMenu = menu; }; @@ -288,6 +315,7 @@ namespace Pinetime { ChimesOption chimesOption = ChimesOption::None; PineTimeStyle PTS; + Analog A; WatchFaceInfineat watchFaceInfineat; diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 13859c448c..3b3ee1d97b 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -39,6 +39,11 @@ namespace { .y = CoordinateYRelocate(radius * static_cast(Cosine(angle)) / LV_TRIG_SCALE)}; } + void event_handler(lv_obj_t* obj, lv_event_t event) { + auto* screen = static_cast(obj->user_data); + screen->UpdateSelected(obj, event); + } + } WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, @@ -91,9 +96,24 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, twelve = lv_label_create(lv_scr_act(), nullptr); lv_label_set_align(twelve, LV_LABEL_ALIGN_CENTER); lv_label_set_text_static(twelve, "12"); - lv_obj_set_pos(twelve, 110, 10); + if (settingsController.GetA24HourMode() == Pinetime::Controllers::Settings::A24HourMode::On) { + lv_obj_set_pos(twelve, 110, 210); + } else { + lv_obj_set_pos(twelve, 110, 10); + } lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + zero = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(zero, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(zero, "00"); + lv_obj_set_pos(zero, 110, 10); + lv_obj_set_style_local_text_color(zero, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + if (settingsController.GetA24HourMode() == Pinetime::Controllers::Settings::A24HourMode::On) { + lv_obj_set_hidden(zero, false); + } else { + lv_obj_set_hidden(zero, true); + } + batteryIcon.Create(lv_scr_act()); lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0); @@ -129,6 +149,11 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, lv_style_set_line_color(&second_line_style, LV_STATE_DEFAULT, LV_COLOR_RED); lv_style_set_line_rounded(&second_line_style, LV_STATE_DEFAULT, true); lv_obj_add_style(second_body, LV_LINE_PART_MAIN, &second_line_style); + if (settingsController.GetASecondHand() == Pinetime::Controllers::Settings::ASecondHand::On) { + lv_obj_set_hidden(second_body, false); + } else { + lv_obj_set_hidden(second_body, true); + } lv_style_init(&minute_line_style); lv_style_set_line_width(&minute_line_style, LV_STATE_DEFAULT, 3); @@ -154,6 +179,36 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, /* lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false); */ /* lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace); */ + btnClose = lv_btn_create(lv_scr_act(), nullptr); + btnClose->user_data = this; + lv_obj_set_size(btnClose, 60, 60); + lv_obj_align(btnClose, lv_scr_act(), LV_ALIGN_CENTER, 0, -80); + lv_obj_set_style_local_bg_opa(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); + lv_obj_t* lblClose = lv_label_create(btnClose, nullptr); + lv_label_set_text_static(lblClose, "X"); + lv_obj_set_event_cb(btnClose, event_handler); + lv_obj_set_hidden(btnClose, true); + + btn24HourMode = lv_btn_create(lv_scr_act(), nullptr); + btn24HourMode->user_data = this; + lv_obj_set_size(btn24HourMode, 160, 60); + lv_obj_align(btn24HourMode, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); + lv_obj_set_style_local_bg_opa(btn24HourMode, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); + lv_obj_t* lbl24HourMode = lv_label_create(btn24HourMode, nullptr); + lv_label_set_text_static(lbl24HourMode, "Toggle 24h"); + lv_obj_set_event_cb(btn24HourMode, event_handler); + lv_obj_set_hidden(btn24HourMode, true); + + btnSecondHand = lv_btn_create(lv_scr_act(), nullptr); + btnSecondHand->user_data = this; + lv_obj_set_size(btnSecondHand, 160, 60); + lv_obj_align(btnSecondHand, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); + lv_obj_set_style_local_bg_opa(btnSecondHand, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); + lv_obj_t* lblSecondHand = lv_label_create(btnSecondHand, nullptr); + lv_label_set_text_static(lblSecondHand, "Seconds"); + lv_obj_set_event_cb(btnSecondHand, event_handler); + lv_obj_set_hidden(btnSecondHand, true); + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); Refresh(); @@ -171,6 +226,37 @@ WatchFaceAnalog::~WatchFaceAnalog() { lv_obj_clean(lv_scr_act()); } +/* Begin Settings */ +bool WatchFaceAnalog::OnTouchEvent(Pinetime::Applications::TouchEvents event) { + if ((event == Pinetime::Applications::TouchEvents::LongTap) && lv_obj_get_hidden(btnClose)) { + lv_obj_set_hidden(btnClose, false); + lv_obj_set_hidden(btn24HourMode, false); + lv_obj_set_hidden(btnSecondHand, false); + savedTick = lv_tick_get(); + return true; + } + if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && (lv_obj_get_hidden(btnClose) == false)) { + return true; + } + return false; +} + +void WatchFaceAnalog::CloseMenu() { + settingsController.SaveSettings(); + lv_obj_set_hidden(btnClose, true); + lv_obj_set_hidden(btn24HourMode, true); + lv_obj_set_hidden(btnSecondHand, true); +} + +bool WatchFaceAnalog::OnButtonPushed() { + if (!lv_obj_get_hidden(btnClose)) { + CloseMenu(); + return true; + } + return false; +} +/* End Settings */ + void WatchFaceAnalog::UpdateClock() { uint8_t hour = dateTimeController.Hours(); uint8_t minute = dateTimeController.Minutes(); @@ -262,3 +348,31 @@ void WatchFaceAnalog::Refresh() { } } } + +void WatchFaceAnalog::UpdateSelected(lv_obj_t* object, lv_event_t event) { + if (event == LV_EVENT_CLICKED) { + if (object == btnClose) { + CloseMenu(); + } + if (object == btn24HourMode) { + if (lv_obj_get_hidden(zero)) { + // set mode to 24 hours + lv_obj_set_pos(twelve, 110, 210); + lv_obj_set_hidden(zero, false); + settingsController.SetA24HourMode(Controllers::Settings::A24HourMode::On); + } else { + // set mode to 12 hours + lv_obj_set_pos(twelve, 110, 10); + lv_obj_set_hidden(zero, true); + settingsController.SetA24HourMode(Controllers::Settings::A24HourMode::Off); + } + } + if (object == btnSecondHand) { + if (lv_obj_get_hidden(second_body)) { + lv_obj_set_hidden(second_body, false); + } else { + lv_obj_set_hidden(second_body, true); + } + } + } +} diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h index 946dbc11eb..45f8ee8161 100644 --- a/src/displayapp/screens/WatchFaceAnalog.h +++ b/src/displayapp/screens/WatchFaceAnalog.h @@ -33,10 +33,16 @@ namespace Pinetime { ~WatchFaceAnalog() override; + bool OnTouchEvent(TouchEvents event) override; + bool OnButtonPushed() override; + void Refresh() override; + void UpdateSelected(lv_obj_t* object, lv_event_t event); + private: uint8_t sHour, sMinute, sSecond; + uint32_t savedTick = 0; Utility::DirtyValue batteryPercentRemaining {0}; Utility::DirtyValue isCharging {}; @@ -46,10 +52,14 @@ namespace Pinetime { using days = std::chrono::duration>; // TODO: days is standard in c++20 Utility::DirtyValue> currentDate; + lv_obj_t* btnClose; + lv_obj_t* btn24HourMode; + lv_obj_t* btnSecondHand; lv_obj_t* minor_scales; lv_obj_t* major_scales; lv_obj_t* large_scales; lv_obj_t* twelve; + lv_obj_t* zero; lv_obj_t* hour_body; /* lv_obj_t* hour_body_trace; */ @@ -84,6 +94,7 @@ namespace Pinetime { void UpdateClock(); void SetBatteryIcon(); + void CloseMenu(); lv_task_t* taskRefresh; }; From 7147991b083768e21eea720f1f1d312334ba609c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aaron=20Z=C3=BCger?= Date: Thu, 23 Nov 2023 21:23:26 +0100 Subject: [PATCH 4/6] actually make the 24h menu button change the speed (angle) of the hour hand --- src/displayapp/screens/WatchFaceAnalog.cpp | 25 +++++++++++++++------- src/displayapp/screens/WatchFaceAnalog.h | 2 ++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 3b3ee1d97b..19cf52c4dc 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -62,6 +62,7 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, sHour = 99; sMinute = 99; sSecond = 99; + sTfHourEnable = true; minor_scales = lv_linemeter_create(lv_scr_act(), nullptr); lv_linemeter_set_scale(minor_scales, 300, 51); @@ -96,22 +97,22 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, twelve = lv_label_create(lv_scr_act(), nullptr); lv_label_set_align(twelve, LV_LABEL_ALIGN_CENTER); lv_label_set_text_static(twelve, "12"); - if (settingsController.GetA24HourMode() == Pinetime::Controllers::Settings::A24HourMode::On) { - lv_obj_set_pos(twelve, 110, 210); - } else { - lv_obj_set_pos(twelve, 110, 10); - } lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); zero = lv_label_create(lv_scr_act(), nullptr); lv_label_set_align(zero, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(zero, "00"); + lv_label_set_text_static(zero, "24"); lv_obj_set_pos(zero, 110, 10); lv_obj_set_style_local_text_color(zero, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + if (settingsController.GetA24HourMode() == Pinetime::Controllers::Settings::A24HourMode::On) { + lv_obj_set_pos(twelve, 110, 210); lv_obj_set_hidden(zero, false); + tfHourEnable = true; } else { + lv_obj_set_pos(twelve, 110, 10); lv_obj_set_hidden(zero, true); + tfHourEnable = false; } batteryIcon.Create(lv_scr_act()); @@ -274,10 +275,16 @@ void WatchFaceAnalog::UpdateClock() { /* lv_line_set_points(minute_body_trace, minute_point_trace, 2); */ } - if (sHour != hour || sMinute != minute) { + if (sHour != hour || sMinute != minute || sTfHourEnable != tfHourEnable) { sHour = hour; sMinute = minute; - auto const angle = (hour * 30 + minute / 2); + sTfHourEnable = tfHourEnable; + + auto angle = (hour * 30 + minute / 2); + + if (tfHourEnable == true) { + angle = angle / 2; + } hour_point[0] = CoordinateRelocate(-10, angle); hour_point[1] = CoordinateRelocate(HourLength, angle); @@ -359,11 +366,13 @@ void WatchFaceAnalog::UpdateSelected(lv_obj_t* object, lv_event_t event) { // set mode to 24 hours lv_obj_set_pos(twelve, 110, 210); lv_obj_set_hidden(zero, false); + tfHourEnable = true; settingsController.SetA24HourMode(Controllers::Settings::A24HourMode::On); } else { // set mode to 12 hours lv_obj_set_pos(twelve, 110, 10); lv_obj_set_hidden(zero, true); + tfHourEnable = false; settingsController.SetA24HourMode(Controllers::Settings::A24HourMode::Off); } } diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h index 45f8ee8161..262b7c7aa4 100644 --- a/src/displayapp/screens/WatchFaceAnalog.h +++ b/src/displayapp/screens/WatchFaceAnalog.h @@ -52,6 +52,8 @@ namespace Pinetime { using days = std::chrono::duration>; // TODO: days is standard in c++20 Utility::DirtyValue> currentDate; + bool tfHourEnable, sTfHourEnable; + lv_obj_t* btnClose; lv_obj_t* btn24HourMode; lv_obj_t* btnSecondHand; From afaea707ab168a68db063a76aacaa03494d08ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aaron=20Z=C3=BCger?= Date: Thu, 23 Nov 2023 22:16:42 +0100 Subject: [PATCH 5/6] change watchface (digits and scales) upon 24h toggle --- src/displayapp/screens/WatchFaceAnalog.cpp | 184 ++++++++++++++++++--- src/displayapp/screens/WatchFaceAnalog.h | 12 +- 2 files changed, 172 insertions(+), 24 deletions(-) diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 19cf52c4dc..352480aeab 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -65,7 +65,11 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, sTfHourEnable = true; minor_scales = lv_linemeter_create(lv_scr_act(), nullptr); - lv_linemeter_set_scale(minor_scales, 300, 51); + if (settingsController.GetA24HourMode() == Pinetime::Controllers::Settings::A24HourMode::On) { + lv_linemeter_set_scale(minor_scales, 360, 61); + } else { + lv_linemeter_set_scale(minor_scales, 300, 51); + } lv_linemeter_set_angle_offset(minor_scales, 180); lv_obj_set_size(minor_scales, 240, 240); lv_obj_align(minor_scales, nullptr, LV_ALIGN_CENTER, 0, 0); @@ -75,43 +79,143 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, lv_obj_set_style_local_scale_end_color(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); major_scales = lv_linemeter_create(lv_scr_act(), nullptr); - lv_linemeter_set_scale(major_scales, 300, 11); - lv_linemeter_set_angle_offset(major_scales, 180); + if (settingsController.GetA24HourMode() == Pinetime::Controllers::Settings::A24HourMode::On) { + lv_linemeter_set_scale(major_scales, 360, 13); + lv_linemeter_set_angle_offset(major_scales, 30); + lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); + lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 2); + } else { + lv_linemeter_set_scale(major_scales, 300, 11); + lv_linemeter_set_angle_offset(major_scales, 180); + lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 6); + lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); + } lv_obj_set_size(major_scales, 240, 240); lv_obj_align(major_scales, nullptr, LV_ALIGN_CENTER, 0, 0); lv_obj_set_style_local_bg_opa(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 6); - lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + large_scales = lv_linemeter_create(lv_scr_act(), nullptr); - lv_linemeter_set_scale(large_scales, 180, 3); - lv_linemeter_set_angle_offset(large_scales, 180); - lv_obj_set_size(large_scales, 240, 240); - lv_obj_align(large_scales, nullptr, LV_ALIGN_CENTER, 0, 0); + if (settingsController.GetA24HourMode() == Pinetime::Controllers::Settings::A24HourMode::On) { + lv_linemeter_set_scale(large_scales, 360, 13); + lv_linemeter_set_angle_offset(large_scales, 15); + lv_obj_set_size(large_scales, 225, 225); + lv_obj_align(large_scales, nullptr, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_style_local_scale_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 10); + lv_obj_set_style_local_scale_end_line_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 3); + } else { + lv_linemeter_set_scale(large_scales, 180, 3); + lv_linemeter_set_angle_offset(large_scales, 180); + lv_obj_set_size(large_scales, 240, 240); + lv_obj_align(large_scales, nullptr, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_style_local_scale_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 20); + lv_obj_set_style_local_scale_end_line_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); + } lv_obj_set_style_local_bg_opa(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_scale_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 20); - lv_obj_set_style_local_scale_end_line_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); lv_obj_set_style_local_scale_end_color(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + zero = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(zero, LV_LABEL_ALIGN_CENTER); + lv_label_set_text_static(zero, "24"); + lv_obj_set_pos(zero, 107, 17); + lv_obj_set_style_local_text_color(zero, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + + /* two = lv_label_create(lv_scr_act(), nullptr); */ + /* lv_label_set_align(two, LV_LABEL_ALIGN_CENTER); */ + /* lv_label_set_text_static(two, "2"); */ + /* lv_obj_set_pos(two, 160, 30); */ + /* lv_obj_set_style_local_text_color(two, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); */ + + /* four = lv_label_create(lv_scr_act(), nullptr); */ + /* lv_label_set_align(four, LV_LABEL_ALIGN_CENTER); */ + /* lv_label_set_text_static(four, "4"); */ + /* lv_obj_set_pos(four, 192, 60); */ + /* lv_obj_set_style_local_text_color(four, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); */ + + /* six = lv_label_create(lv_scr_act(), nullptr); */ + /* lv_label_set_align(six, LV_LABEL_ALIGN_CENTER); */ + /* lv_label_set_text_static(six, "6"); */ + /* lv_obj_set_pos(six, 206, 107); */ + /* lv_obj_set_style_local_text_color(six, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); */ + + /* eight = lv_label_create(lv_scr_act(), nullptr); */ + /* lv_label_set_align(eight, LV_LABEL_ALIGN_CENTER); */ + /* lv_label_set_text_static(eight, "8"); */ + /* lv_obj_set_pos(eight, 192, 154); */ + /* lv_obj_set_style_local_text_color(eight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); */ + + /* ten = lv_label_create(lv_scr_act(), nullptr); */ + /* lv_label_set_align(ten, LV_LABEL_ALIGN_CENTER); */ + /* lv_label_set_text_static(ten, "10"); */ + /* lv_obj_set_pos(ten, 153, 184); */ + /* lv_obj_set_style_local_text_color(ten, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); */ + twelve = lv_label_create(lv_scr_act(), nullptr); lv_label_set_align(twelve, LV_LABEL_ALIGN_CENTER); lv_label_set_text_static(twelve, "12"); + if (settingsController.GetA24HourMode() == Pinetime::Controllers::Settings::A24HourMode::On) { + lv_obj_set_pos(twelve, 107, 198); + } else { + lv_obj_set_pos(twelve, 107, 10); + } lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - zero = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(zero, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(zero, "24"); - lv_obj_set_pos(zero, 110, 10); - lv_obj_set_style_local_text_color(zero, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + /* fourteen = lv_label_create(lv_scr_act(), nullptr); */ + /* lv_label_set_align(fourteen, LV_LABEL_ALIGN_CENTER); */ + /* lv_label_set_text_static(fourteen, "14"); */ + /* lv_obj_set_pos(fourteen, 62, 184); */ + /* lv_obj_set_style_local_text_color(fourteen, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); */ + + /* sixteen = lv_label_create(lv_scr_act(), nullptr); */ + /* lv_label_set_align(sixteen, LV_LABEL_ALIGN_CENTER); */ + /* lv_label_set_text_static(sixteen, "16"); */ + /* lv_obj_set_pos(sixteen, 32, 152); */ + /* lv_obj_set_style_local_text_color(sixteen, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); */ + + /* eighteen = lv_label_create(lv_scr_act(), nullptr); */ + /* lv_label_set_align(eighteen, LV_LABEL_ALIGN_CENTER); */ + /* lv_label_set_text_static(eighteen, "18"); */ + /* lv_obj_set_pos(eighteen, 20, 107); */ + /* lv_obj_set_style_local_text_color(eighteen, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); */ + + /* twenty = lv_label_create(lv_scr_act(), nullptr); */ + /* lv_label_set_align(twenty, LV_LABEL_ALIGN_CENTER); */ + /* lv_label_set_text_static(twenty, "20"); */ + /* lv_obj_set_pos(twenty, 32, 62); */ + /* lv_obj_set_style_local_text_color(twenty, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); */ + + /* twentytwo = lv_label_create(lv_scr_act(), nullptr); */ + /* lv_label_set_align(twentytwo, LV_LABEL_ALIGN_CENTER); */ + /* lv_label_set_text_static(twentytwo, "22"); */ + /* lv_obj_set_pos(twentytwo, 62, 30); */ + /* lv_obj_set_style_local_text_color(twentytwo, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); */ if (settingsController.GetA24HourMode() == Pinetime::Controllers::Settings::A24HourMode::On) { - lv_obj_set_pos(twelve, 110, 210); lv_obj_set_hidden(zero, false); + /* lv_obj_set_hidden(two, false); */ + /* lv_obj_set_hidden(four, false); */ + /* lv_obj_set_hidden(six, false); */ + /* lv_obj_set_hidden(eight, false); */ + /* lv_obj_set_hidden(ten, false); */ + /* lv_obj_set_hidden(fourteen, false); */ + /* lv_obj_set_hidden(sixteen, false); */ + /* lv_obj_set_hidden(eighteen, false); */ + /* lv_obj_set_hidden(twenty, false); */ + /* lv_obj_set_hidden(twentytwo, false); */ tfHourEnable = true; } else { - lv_obj_set_pos(twelve, 110, 10); lv_obj_set_hidden(zero, true); + /* lv_obj_set_hidden(two, true); */ + /* lv_obj_set_hidden(four, true); */ + /* lv_obj_set_hidden(six, true); */ + /* lv_obj_set_hidden(eight, true); */ + /* lv_obj_set_hidden(ten, true); */ + /* lv_obj_set_hidden(fourteen, true); */ + /* lv_obj_set_hidden(sixteen, true); */ + /* lv_obj_set_hidden(eighteen, true); */ + /* lv_obj_set_hidden(twenty, true); */ + /* lv_obj_set_hidden(twentytwo, true); */ tfHourEnable = false; } @@ -361,21 +465,55 @@ void WatchFaceAnalog::UpdateSelected(lv_obj_t* object, lv_event_t event) { if (object == btnClose) { CloseMenu(); } + if (object == btn24HourMode) { - if (lv_obj_get_hidden(zero)) { + if (tfHourEnable == false) { // set mode to 24 hours - lv_obj_set_pos(twelve, 110, 210); - lv_obj_set_hidden(zero, false); tfHourEnable = true; + // digits + lv_obj_set_pos(twelve, 107, 198); + lv_obj_set_hidden(zero, false); + // scales + lv_linemeter_set_scale(minor_scales, 360, 61); + + lv_linemeter_set_scale(major_scales, 360, 13); + lv_linemeter_set_angle_offset(major_scales, 30); + lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); + lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 2); + + lv_linemeter_set_scale(large_scales, 360, 13); + lv_linemeter_set_angle_offset(large_scales, 15); + lv_obj_set_size(large_scales, 225, 225); + lv_obj_align(large_scales, nullptr, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_style_local_scale_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 10); + lv_obj_set_style_local_scale_end_line_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 3); + settingsController.SetA24HourMode(Controllers::Settings::A24HourMode::On); } else { // set mode to 12 hours - lv_obj_set_pos(twelve, 110, 10); - lv_obj_set_hidden(zero, true); tfHourEnable = false; + // digits + lv_obj_set_pos(twelve, 107, 10); + lv_obj_set_hidden(zero, true); + // scales + lv_linemeter_set_scale(minor_scales, 300, 51); + + lv_linemeter_set_scale(major_scales, 300, 11); + lv_linemeter_set_angle_offset(major_scales, 180); + lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 6); + lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); + + lv_linemeter_set_scale(large_scales, 180, 3); + lv_linemeter_set_angle_offset(large_scales, 180); + lv_obj_set_size(large_scales, 240, 240); + lv_obj_align(large_scales, nullptr, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_style_local_scale_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 20); + lv_obj_set_style_local_scale_end_line_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); + settingsController.SetA24HourMode(Controllers::Settings::A24HourMode::Off); } } + if (object == btnSecondHand) { if (lv_obj_get_hidden(second_body)) { lv_obj_set_hidden(second_body, false); diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h index 262b7c7aa4..196669945a 100644 --- a/src/displayapp/screens/WatchFaceAnalog.h +++ b/src/displayapp/screens/WatchFaceAnalog.h @@ -60,8 +60,18 @@ namespace Pinetime { lv_obj_t* minor_scales; lv_obj_t* major_scales; lv_obj_t* large_scales; - lv_obj_t* twelve; lv_obj_t* zero; + /* lv_obj_t* two; */ + /* lv_obj_t* four; */ + /* lv_obj_t* six; */ + /* lv_obj_t* eight; */ + /* lv_obj_t* ten; */ + lv_obj_t* twelve; + /* lv_obj_t* fourteen; */ + /* lv_obj_t* sixteen; */ + /* lv_obj_t* eighteen; */ + /* lv_obj_t* twenty; */ + /* lv_obj_t* twentytwo; */ lv_obj_t* hour_body; /* lv_obj_t* hour_body_trace; */ From f0de88b024d256ef856433736be29ea1544ddf84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aaron=20Z=C3=BCger?= Date: Thu, 23 Nov 2023 22:50:14 +0100 Subject: [PATCH 6/6] remove residue from WatchFaceSlowTime --- src/CMakeLists.txt | 1 - src/displayapp/WatchFaces.h | 5 +- src/displayapp/screens/Clock.cpp | 11 - src/displayapp/screens/Clock.h | 1 - src/displayapp/screens/WatchFaceSlowTime.cpp | 286 ------------------ src/displayapp/screens/WatchFaceSlowTime.h | 94 ------ .../screens/settings/SettingWatchFace.h | 3 +- 7 files changed, 3 insertions(+), 398 deletions(-) delete mode 100644 src/displayapp/screens/WatchFaceSlowTime.cpp delete mode 100644 src/displayapp/screens/WatchFaceSlowTime.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9f5bb16abf..dc718bab13 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -432,7 +432,6 @@ list(APPEND SOURCE_FILES displayapp/screens/WatchFaceTerminal.cpp displayapp/screens/WatchFacePineTimeStyle.cpp displayapp/screens/WatchFaceCasioStyleG7710.cpp - displayapp/screens/WatchFaceSlowTime.cpp ## diff --git a/src/displayapp/WatchFaces.h b/src/displayapp/WatchFaces.h index f24353ea28..2982347aa1 100644 --- a/src/displayapp/WatchFaces.h +++ b/src/displayapp/WatchFaces.h @@ -7,9 +7,8 @@ namespace Pinetime { Analog = 1, PineTimeStyle = 2, Terminal = 3, - SlowTime = 4, - Infineat = 5, - CasioStyleG7710 = 6, + Infineat = 4, + CasioStyleG7710 = 5, }; } } diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index 7581bc25f2..f898c4ed3f 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -13,7 +13,6 @@ #include "displayapp/screens/WatchFaceAnalog.h" #include "displayapp/screens/WatchFacePineTimeStyle.h" #include "displayapp/screens/WatchFaceCasioStyleG7710.h" -#include "displayapp/screens/WatchFaceSlowTime.h" using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications; @@ -56,9 +55,6 @@ Clock::Clock(Controllers::DateTime& dateTimeController, case WatchFace::CasioStyleG7710: return WatchFaceCasioStyleG7710(); break; - case WatchFace::SlowTime: - return WatchFaceSlowTimeScreen(); - break; } return WatchFaceDigitalScreen(); }()} { @@ -136,10 +132,3 @@ std::unique_ptr Clock::WatchFaceCasioStyleG7710() { filesystem); } -std::unique_ptr Clock::WatchFaceSlowTimeScreen() { - return std::make_unique(dateTimeController, - batteryController, - bleController, - notificationManager, - settingsController); -} diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h index 3be111f5ee..e67c0260f4 100644 --- a/src/displayapp/screens/Clock.h +++ b/src/displayapp/screens/Clock.h @@ -57,7 +57,6 @@ namespace Pinetime { std::unique_ptr WatchFaceTerminalScreen(); std::unique_ptr WatchFaceInfineatScreen(); std::unique_ptr WatchFaceCasioStyleG7710(); - std::unique_ptr WatchFaceSlowTimeScreen(); }; } } diff --git a/src/displayapp/screens/WatchFaceSlowTime.cpp b/src/displayapp/screens/WatchFaceSlowTime.cpp deleted file mode 100644 index 0ecbc79bd7..0000000000 --- a/src/displayapp/screens/WatchFaceSlowTime.cpp +++ /dev/null @@ -1,286 +0,0 @@ -#include "displayapp/screens/WatchFaceSlowTime.h" -#include -#include -#include "displayapp/screens/BatteryIcon.h" -#include "displayapp/screens/BleIcon.h" -#include "displayapp/screens/Symbols.h" -#include "displayapp/screens/NotificationIcon.h" -#include "components/settings/Settings.h" -#include "displayapp/InfiniTimeTheme.h" - -using namespace Pinetime::Applications::Screens; - -namespace { - constexpr int16_t HourLength = 50; - constexpr int16_t MinuteLength = 80; - - // 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 Sine(int16_t angle) { - return _lv_trigo_sin(angle); - } - - 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); - } - - 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)}; - } - -} - -WatchFaceSlowTime::WatchFaceSlowTime(Controllers::DateTime& dateTimeController, - const Controllers::Battery& batteryController, - const Controllers::Ble& bleController, - Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController) - : currentDateTime {{}}, - batteryIcon(true), - dateTimeController {dateTimeController}, - batteryController {batteryController}, - bleController {bleController}, - notificationManager {notificationManager}, - settingsController {settingsController} { - - sHour = 99; - sMinute = 99; - - minor_scales = lv_linemeter_create(lv_scr_act(), nullptr); - lv_linemeter_set_scale(minor_scales, 360, 61); - lv_linemeter_set_angle_offset(minor_scales, 180); - lv_obj_set_size(minor_scales, 240, 240); - lv_obj_align(minor_scales, nullptr, LV_ALIGN_CENTER, 0, 0); - lv_obj_set_style_local_bg_opa(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_scale_width(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); - lv_obj_set_style_local_scale_end_line_width(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 1); - lv_obj_set_style_local_scale_end_color(minor_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); - - major_scales= lv_linemeter_create(lv_scr_act(), nullptr); - lv_linemeter_set_scale(major_scales, 360, 13); - lv_linemeter_set_angle_offset(major_scales, 30); - lv_obj_set_size(major_scales, 240, 240); - lv_obj_align(major_scales, nullptr, LV_ALIGN_CENTER, 0, 0); - lv_obj_set_style_local_bg_opa(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); - lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 2); - lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - - large_scales= lv_linemeter_create(lv_scr_act(), nullptr); - lv_linemeter_set_scale(large_scales, 360, 13); - lv_linemeter_set_angle_offset(large_scales, 15); - lv_obj_set_size(large_scales, 220, 220); - lv_obj_align(large_scales, nullptr, LV_ALIGN_CENTER, 0, 0); - lv_obj_set_style_local_bg_opa(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_scale_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 10); - lv_obj_set_style_local_scale_end_line_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_scale_end_color(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - two = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(two, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(two, "2"); - lv_obj_set_pos(two, 160, 30); - lv_obj_set_style_local_text_color(two, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - four = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(four, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(four, "4"); - lv_obj_set_pos(four, 192, 60); - lv_obj_set_style_local_text_color(four, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - six = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(six, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(six, "6"); - lv_obj_set_pos(six, 206, 107); - lv_obj_set_style_local_text_color(six, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - eight = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(eight, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(eight, "8"); - lv_obj_set_pos(eight, 192, 154); - lv_obj_set_style_local_text_color(eight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - ten = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(ten, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(ten, "10"); - lv_obj_set_pos(ten, 153, 184); - lv_obj_set_style_local_text_color(ten, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - twelve = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(twelve, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(twelve, "12"); - lv_obj_set_pos(twelve, 107, 198); - lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - fourteen = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(fourteen, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(fourteen, "14"); - lv_obj_set_pos(fourteen, 62, 184); - lv_obj_set_style_local_text_color(fourteen, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - sixteen = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(sixteen, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(sixteen, "16"); - lv_obj_set_pos(sixteen, 32, 152); - lv_obj_set_style_local_text_color(sixteen, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - eighteen = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(eighteen, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(eighteen, "18"); - lv_obj_set_pos(eighteen, 20, 107); - lv_obj_set_style_local_text_color(eighteen, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - twenty = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(twenty, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(twenty, "20"); - lv_obj_set_pos(twenty, 32, 62); - lv_obj_set_style_local_text_color(twenty, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - twentytwo = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(twentytwo, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(twentytwo, "22"); - lv_obj_set_pos(twentytwo, 62, 30); - lv_obj_set_style_local_text_color(twentytwo, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - twentyfour = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_align(twentyfour, LV_LABEL_ALIGN_CENTER); - lv_label_set_text_static(twentyfour, "24"); - lv_obj_set_pos(twentyfour, 107, 17); - lv_obj_set_style_local_text_color(twentyfour, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - - batteryIcon.Create(lv_scr_act()); - lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0); - - plugIcon = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_text_static(plugIcon, Symbols::plug); - lv_obj_align(plugIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0); - - bleIcon = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_text_static(bleIcon, ""); - lv_obj_align(bleIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, -30, 0); - - notificationIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_LIME); - lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); - lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); - - // Date - Day / Week day - - label_date_day = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAROON); - lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); - lv_label_set_align(label_date_day, LV_LABEL_ALIGN_CENTER); - lv_obj_align(label_date_day, nullptr, LV_ALIGN_CENTER, 50, 0); - - minute_body = lv_line_create(lv_scr_act(), nullptr); - hour_body = lv_line_create(lv_scr_act(), nullptr); - - lv_style_init(&minute_line_style); - lv_style_set_line_width(&minute_line_style, LV_STATE_DEFAULT, 3); - lv_style_set_line_color(&minute_line_style, LV_STATE_DEFAULT, LV_COLOR_TEAL); - lv_style_set_line_rounded(&minute_line_style, LV_STATE_DEFAULT, true); - lv_obj_add_style(minute_body, LV_LINE_PART_MAIN, &minute_line_style); - - lv_style_init(&hour_line_style); - lv_style_set_line_width(&hour_line_style, LV_STATE_DEFAULT, 5); - lv_style_set_line_color(&hour_line_style, LV_STATE_DEFAULT, LV_COLOR_TEAL); - lv_style_set_line_rounded(&hour_line_style, LV_STATE_DEFAULT, true); - lv_obj_add_style(hour_body, LV_LINE_PART_MAIN, &hour_line_style); - - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); - - Refresh(); -} - -WatchFaceSlowTime::~WatchFaceSlowTime() { - lv_task_del(taskRefresh); - - lv_style_reset(&hour_line_style); - lv_style_reset(&minute_line_style); - - lv_obj_clean(lv_scr_act()); -} - -void WatchFaceSlowTime::UpdateClock() { - uint8_t hour = dateTimeController.Hours(); - uint8_t minute = dateTimeController.Minutes(); - - if (sMinute != minute) { - auto const angle = minute * 6; - minute_point[0] = CoordinateRelocate(-15, angle); - minute_point[1] = CoordinateRelocate(MinuteLength, angle); - - lv_line_set_points(minute_body, minute_point, 2); - } - - if (sHour != hour || sMinute != minute) { - sHour = hour; - sMinute = minute; - auto const angle = (hour * 15 + minute / 4); - - hour_point[0] = CoordinateRelocate(-15, angle); - hour_point[1] = CoordinateRelocate(HourLength, angle); - - lv_line_set_points(hour_body, hour_point, 2); - } -} - -void WatchFaceSlowTime::SetBatteryIcon() { - auto batteryPercent = batteryPercentRemaining.Get(); - batteryIcon.SetBatteryPercentage(batteryPercent); -} - -void WatchFaceSlowTime::Refresh() { - isCharging = batteryController.IsCharging(); - if (isCharging.IsUpdated()) { - if (isCharging.Get()) { - lv_obj_set_hidden(batteryIcon.GetObject(), true); - lv_obj_set_hidden(plugIcon, false); - } else { - lv_obj_set_hidden(batteryIcon.GetObject(), false); - lv_obj_set_hidden(plugIcon, true); - SetBatteryIcon(); - } - } - if (!isCharging.Get()) { - batteryPercentRemaining = batteryController.PercentRemaining(); - if (batteryPercentRemaining.IsUpdated()) { - SetBatteryIcon(); - } - } - - bleState = bleController.IsConnected(); - if (bleState.IsUpdated()) { - if (bleState.Get()) { - lv_label_set_text_static(bleIcon, Symbols::bluetooth); - } else { - lv_label_set_text_static(bleIcon, ""); - } - } - - notificationState = notificationManager.AreNewNotificationsAvailable(); - - if (notificationState.IsUpdated()) { - lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); - } - - currentDateTime = dateTimeController.CurrentDateTime(); - if (currentDateTime.IsUpdated()) { - UpdateClock(); - - currentDate = std::chrono::time_point_cast(currentDateTime.Get()); - if (currentDate.IsUpdated()) { - lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); - } - } -} diff --git a/src/displayapp/screens/WatchFaceSlowTime.h b/src/displayapp/screens/WatchFaceSlowTime.h deleted file mode 100644 index e8e24c4e0a..0000000000 --- a/src/displayapp/screens/WatchFaceSlowTime.h +++ /dev/null @@ -1,94 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include "displayapp/screens/Screen.h" -#include "components/datetime/DateTimeController.h" -#include "components/battery/BatteryController.h" -#include "components/ble/BleController.h" -#include "components/ble/NotificationManager.h" -#include "displayapp/screens/BatteryIcon.h" -#include "utility/DirtyValue.h" - -namespace Pinetime { - namespace Controllers { - class Settings; - class Battery; - class Ble; - class NotificationManager; - } - - namespace Applications { - namespace Screens { - - class WatchFaceSlowTime : public Screen { - public: - WatchFaceSlowTime(Controllers::DateTime& dateTimeController, - const Controllers::Battery& batteryController, - const Controllers::Ble& bleController, - Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController); - - ~WatchFaceSlowTime() override; - - void Refresh() override; - - private: - uint8_t sHour, sMinute; - - Utility::DirtyValue batteryPercentRemaining {0}; - Utility::DirtyValue isCharging {}; - Utility::DirtyValue bleState {}; - Utility::DirtyValue> currentDateTime; - Utility::DirtyValue notificationState {false}; - using days = std::chrono::duration>; // TODO: days is standard in c++20 - Utility::DirtyValue> currentDate; - - lv_obj_t* minor_scales; - lv_obj_t* major_scales; - lv_obj_t* large_scales; - lv_obj_t* two; - lv_obj_t* four; - lv_obj_t* six; - lv_obj_t* eight; - lv_obj_t* ten; - lv_obj_t* twelve; - lv_obj_t* fourteen; - lv_obj_t* sixteen; - lv_obj_t* eighteen; - lv_obj_t* twenty; - lv_obj_t* twentytwo; - lv_obj_t* twentyfour; - - lv_obj_t* hour_body; - lv_obj_t* minute_body; - - lv_point_t hour_point[2]; - lv_point_t minute_point[2]; - - lv_style_t hour_line_style; - lv_style_t minute_line_style; - - lv_obj_t* label_date_day; - lv_obj_t* plugIcon; - lv_obj_t* notificationIcon; - lv_obj_t* bleIcon; - - BatteryIcon batteryIcon; - - const Controllers::DateTime& dateTimeController; - const Controllers::Battery& batteryController; - const Controllers::Ble& bleController; - Controllers::NotificationManager& notificationManager; - Controllers::Settings& settingsController; - - void UpdateClock(); - void SetBatteryIcon(); - - lv_task_t* taskRefresh; - }; - } - } -} diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h index a9d8a5f758..45a50e3d0b 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.h +++ b/src/displayapp/screens/settings/SettingWatchFace.h @@ -11,7 +11,6 @@ #include "displayapp/screens/CheckboxList.h" #include "displayapp/screens/WatchFaceInfineat.h" #include "displayapp/screens/WatchFaceCasioStyleG7710.h" -#include "displayapp/screens/WatchFaceSlowTime.h" namespace Pinetime { @@ -46,9 +45,9 @@ namespace Pinetime { {"Analog face", true}, {"PineTimeStyle", true}, {"Terminal", true}, - {"SlowTime", true}, {"Infineat face", Applications::Screens::WatchFaceInfineat::IsAvailable(filesystem)}, {"Casio G7710", Applications::Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem)}, + {"", false}, {"", false}}}; ScreenList screens; };