From deb8f9368fd38533431c257cc17a30c1bb4fae7b Mon Sep 17 00:00:00 2001 From: Ryan Rix Date: Tue, 26 Sep 2023 01:04:20 -0700 Subject: [PATCH] fuzzy clock --- src/displayapp/fonts/fonts.json | 139 +++++++++--------- src/displayapp/screens/Clock.cpp | 1 - src/displayapp/screens/WatchFaceFuzzy.cpp | 89 ++++++----- src/displayapp/screens/WatchFaceFuzzy.h | 11 +- .../screens/settings/SettingWatchFace.h | 1 - 5 files changed, 122 insertions(+), 119 deletions(-) diff --git a/src/displayapp/fonts/fonts.json b/src/displayapp/fonts/fonts.json index bcfc365f..0879304f 100644 --- a/src/displayapp/fonts/fonts.json +++ b/src/displayapp/fonts/fonts.json @@ -2,76 +2,79 @@ "jetbrains_mono_bold_20": { "sources": [ { - "file": "JetBrainsMono-Bold.ttf", - "range": "0x20-0x7e, 0x410-0x44f, 0xB0" + "file": "Vulf_Mono-Italic.woff", + "range": "0x20-0x7e, 0xB0" }, - { - "file": "FontAwesome5-Solid+Brands+Regular.woff", - "range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c" - } + { + "file": "JetBrainsMono-Bold.ttf", + "range": "0x410-0x44f" + }, + { + "file": "FontAwesome5-Solid+Brands+Regular.woff", + "range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c" + } ], "bpp": 1, - "size": 20, - "patches": ["jetbrains_mono_bold_20.c_zero.patch", "jetbrains_mono_bold_20.c_M.patch"] + "size": 20 }, - "jetbrains_mono_42": { - "sources": [ - { - "file": "JetBrainsMono-Regular.ttf", - "range": "0x25, 0x2b, 0x2d, 0x30-0x3a" - } - ], - "bpp": 1, - "size": 42 - }, - "jetbrains_mono_76": { - "sources": [ - { - "file": "JetBrainsMono-Light.ttf", - "range": "0x25, 0x2D, 0x2F, 0x30-0x3a" - } - ], - "bpp": 1, - "size": 76 - }, - "jetbrains_mono_extrabold_compressed": { - "sources": [ - { - "file": "JetBrainsMono-ExtraBold.ttf", - "range": "0x30-0x3a" - } - ], - "bpp": 1, - "size": 80 - }, - "open_sans_light": { - "sources": [ - { - "file": "open_sans_light.ttf", - "symbols": "0123456789" - } - ], - "bpp": 1, - "size": 150 - }, - "lv_font_sys_48": { - "sources": [ - { - "file": "material-design-icons/MaterialIcons-Regular.ttf", - "range": "0xf00b, 0xe3aa-0xe3ac, 0xe7f6-0xe7f7, 0xe8b8, 0xef44, 0xe40a" - } - ], - "bpp": 1, - "size": 48 - }, - "fontawesome_weathericons": { - "sources": [ - { - "file": "FontAwesome5-Solid+Brands+Regular.woff", - "range": "0xf185, 0xf6c4, 0xf743, 0xf740, 0xf75f, 0xf0c2, 0xf05e" - } - ], - "bpp": 1, - "size": 25 - } + "jetbrains_mono_42": { + "sources": [ + { + "file": "JetBrainsMono-Regular.ttf", + "range": "0x25, 0x2b, 0x2d, 0x30-0x3a" + } + ], + "bpp": 1, + "size": 42 + }, + "jetbrains_mono_76": { + "sources": [ + { + "file": "JetBrainsMono-Light.ttf", + "range": "0x25, 0x2D, 0x2F, 0x30-0x3a" + } + ], + "bpp": 1, + "size": 76 + }, + "jetbrains_mono_extrabold_compressed": { + "sources": [ + { + "file": "JetBrainsMono-ExtraBold.ttf", + "range": "0x20, 0x30-0x3a" + } + ], + "bpp": 1, + "size": 80 + }, + "open_sans_light": { + "sources": [ + { + "file": "open_sans_light.ttf", + "symbols": "0123456789" + } + ], + "bpp": 1, + "size": 150 + }, + "lv_font_sys_48": { + "sources": [ + { + "file": "material-design-icons/MaterialIcons-Regular.ttf", + "range": "0xf00b, 0xe3aa-0xe3ac, 0xe7f6-0xe7f7, 0xe8b8, 0xef44, 0xe40a" + } + ], + "bpp": 1, + "size": 48 + }, + "fontawesome_weathericons": { + "sources": [ + { + "file": "FontAwesome5-Solid+Brands+Regular.woff", + "range": "0xf185, 0xf6c4, 0xf743, 0xf740, 0xf75f, 0xf0c2, 0xf05e" + } + ], + "bpp": 1, + "size": 25 + } } diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index 9eb2090e..b9f4244f 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -99,7 +99,6 @@ std::unique_ptr Clock::WatchFaceFuzzy() { batteryController, bleController, notificationManager, - settingsController, heartRateController, motionController); } diff --git a/src/displayapp/screens/WatchFaceFuzzy.cpp b/src/displayapp/screens/WatchFaceFuzzy.cpp index c69dc3ef..c1bb91db 100644 --- a/src/displayapp/screens/WatchFaceFuzzy.cpp +++ b/src/displayapp/screens/WatchFaceFuzzy.cpp @@ -2,6 +2,9 @@ #include #include +#include +#include +#include #include "displayapp/screens/NotificationIcon.h" #include "displayapp/screens/Symbols.h" #include "components/battery/BatteryController.h" @@ -9,7 +12,6 @@ #include "components/ble/NotificationManager.h" #include "components/heartrate/HeartRateController.h" #include "components/motion/MotionController.h" -#include "components/settings/Settings.h" using namespace Pinetime::Applications::Screens; @@ -17,13 +19,11 @@ WatchFaceFuzzy::WatchFaceFuzzy(Controllers::DateTime& dateTimeController, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, Controllers::MotionController& motionController) : currentDateTime {{}}, dateTimeController {dateTimeController}, notificationManager {notificationManager}, - settingsController {settingsController}, heartRateController {heartRateController}, motionController {motionController}, statusIcons(batteryController, bleController) { @@ -35,18 +35,14 @@ WatchFaceFuzzy::WatchFaceFuzzy(Controllers::DateTime& dateTimeController, lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); - label_date = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); - lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); - label_time = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed); + lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20); + lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20); + lv_label_set_recolor(label_time, true); - lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0); - - label_time_ampm = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_text_static(label_time_ampm, ""); - lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55); + label_date = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); + lv_obj_align(label_date, label_time, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat); @@ -91,43 +87,18 @@ void WatchFaceFuzzy::Refresh() { uint8_t hour = dateTimeController.Hours(); uint8_t minute = dateTimeController.Minutes(); - 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(label_time_ampm, ampmChar); - lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute); - lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0); - } else { - lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute); - lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); - } + printTimeWords(static_cast(hour), static_cast(minute)); currentDate = std::chrono::time_point_cast(currentDateTime.Get()); if (currentDate.IsUpdated()) { uint16_t year = dateTimeController.Year(); uint8_t day = dateTimeController.Day(); - 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_label_set_text_fmt(label_date, + "%s %d %s %d", + dateTimeController.DayOfWeekShortToString(), + day, + dateTimeController.MonthShortToString(), + year); lv_obj_realign(label_date); } } @@ -154,3 +125,31 @@ void WatchFaceFuzzy::Refresh() { lv_obj_realign(stepIcon); } } + +char const* WatchFaceFuzzy::mods[] = {"", "five", "ten", "quarter", "twenty", "twenty five", "half"}; +char const* WatchFaceFuzzy::nums[] = {"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve"}; + +void WatchFaceFuzzy::printTimeWords(int h, int m) { + const char* mod; + if (m <= 30) { + mod = mods[m / 5]; + } else { + mod = mods[(60-m) / 5]; + } + h = (h % 12); + + if (m == 0 || m < 3 || m > 57) { + sprintf(timeStr, "#ffffff %s#\n#808080 o' clock#", nums[h]); + + } + + else if (m <= 30) { + sprintf(timeStr, "#ffffff %s#\n#808080 past# #FFFFFF %s#", mod, nums[h]); + } + + else if (m > 30) { + sprintf(timeStr, "#ffffff %s#\n#808080 to# #FFFFFF %s#", mod, nums[(h % 12) + 1]); + } + + lv_label_set_text(label_time, timeStr); +} diff --git a/src/displayapp/screens/WatchFaceFuzzy.h b/src/displayapp/screens/WatchFaceFuzzy.h index 9866917b..43a99497 100644 --- a/src/displayapp/screens/WatchFaceFuzzy.h +++ b/src/displayapp/screens/WatchFaceFuzzy.h @@ -12,7 +12,6 @@ namespace Pinetime { namespace Controllers { - class Settings; class Battery; class Ble; class NotificationManager; @@ -29,7 +28,6 @@ namespace Pinetime { const Controllers::Battery& batteryController, const Controllers::Ble& bleController, Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, Controllers::MotionController& motionController); ~WatchFaceFuzzy() override; @@ -40,6 +38,11 @@ namespace Pinetime { uint8_t displayedHour = -1; uint8_t displayedMinute = -1; + static char const *nums[]; + static char const *mods[]; + + char timeStr[64]; + Utility::DirtyValue batteryPercentRemaining {}; Utility::DirtyValue powerPresent {}; Utility::DirtyValue bleState {}; @@ -53,7 +56,6 @@ namespace Pinetime { Utility::DirtyValue> currentDate; lv_obj_t* label_time; - lv_obj_t* label_time_ampm; lv_obj_t* label_date; lv_obj_t* heartbeatIcon; lv_obj_t* heartbeatValue; @@ -63,12 +65,13 @@ namespace Pinetime { Controllers::DateTime& dateTimeController; Controllers::NotificationManager& notificationManager; - Controllers::Settings& settingsController; Controllers::HeartRateController& heartRateController; Controllers::MotionController& motionController; lv_task_t* taskRefresh; Widgets::StatusIcons statusIcons; + + void printTimeWords(int h, int m); }; } } diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h index 7b6c5a76..2dd543e6 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.h +++ b/src/displayapp/screens/settings/SettingWatchFace.h @@ -9,7 +9,6 @@ #include "displayapp/screens/Screen.h" #include "displayapp/screens/Symbols.h" #include "displayapp/screens/CheckboxList.h" -#include "displayapp/screens/WatchFaceInfineat.h" #include "displayapp/screens/WatchFaceCasioStyleG7710.h" #include "displayapp/screens/WatchFaceFuzzy.h"