fuzzy clock

This commit is contained in:
Ryan Rix 2023-09-26 01:04:20 -07:00
parent 3ade3153e5
commit deb8f9368f
5 changed files with 122 additions and 119 deletions

View File

@ -1,9 +1,13 @@
{ {
"jetbrains_mono_bold_20": { "jetbrains_mono_bold_20": {
"sources": [ "sources": [
{
"file": "Vulf_Mono-Italic.woff",
"range": "0x20-0x7e, 0xB0"
},
{ {
"file": "JetBrainsMono-Bold.ttf", "file": "JetBrainsMono-Bold.ttf",
"range": "0x20-0x7e, 0x410-0x44f, 0xB0" "range": "0x410-0x44f"
}, },
{ {
"file": "FontAwesome5-Solid+Brands+Regular.woff", "file": "FontAwesome5-Solid+Brands+Regular.woff",
@ -11,8 +15,7 @@
} }
], ],
"bpp": 1, "bpp": 1,
"size": 20, "size": 20
"patches": ["jetbrains_mono_bold_20.c_zero.patch", "jetbrains_mono_bold_20.c_M.patch"]
}, },
"jetbrains_mono_42": { "jetbrains_mono_42": {
"sources": [ "sources": [
@ -38,7 +41,7 @@
"sources": [ "sources": [
{ {
"file": "JetBrainsMono-ExtraBold.ttf", "file": "JetBrainsMono-ExtraBold.ttf",
"range": "0x30-0x3a" "range": "0x20, 0x30-0x3a"
} }
], ],
"bpp": 1, "bpp": 1,

View File

@ -99,7 +99,6 @@ std::unique_ptr<Screen> Clock::WatchFaceFuzzy() {
batteryController, batteryController,
bleController, bleController,
notificationManager, notificationManager,
settingsController,
heartRateController, heartRateController,
motionController); motionController);
} }

View File

@ -2,6 +2,9 @@
#include <lvgl/lvgl.h> #include <lvgl/lvgl.h>
#include <cstdio> #include <cstdio>
#include <lvgl/src/lv_core/lv_obj_style_dec.h>
#include <lvgl/src/lv_font/lv_font.h>
#include <lvgl/src/lv_misc/lv_area.h>
#include "displayapp/screens/NotificationIcon.h" #include "displayapp/screens/NotificationIcon.h"
#include "displayapp/screens/Symbols.h" #include "displayapp/screens/Symbols.h"
#include "components/battery/BatteryController.h" #include "components/battery/BatteryController.h"
@ -9,7 +12,6 @@
#include "components/ble/NotificationManager.h" #include "components/ble/NotificationManager.h"
#include "components/heartrate/HeartRateController.h" #include "components/heartrate/HeartRateController.h"
#include "components/motion/MotionController.h" #include "components/motion/MotionController.h"
#include "components/settings/Settings.h"
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
@ -17,13 +19,11 @@ WatchFaceFuzzy::WatchFaceFuzzy(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController, const Controllers::Battery& batteryController,
const Controllers::Ble& bleController, const Controllers::Ble& bleController,
Controllers::NotificationManager& notificationManager, Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController, Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController) Controllers::MotionController& motionController)
: currentDateTime {{}}, : currentDateTime {{}},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
notificationManager {notificationManager}, notificationManager {notificationManager},
settingsController {settingsController},
heartRateController {heartRateController}, heartRateController {heartRateController},
motionController {motionController}, motionController {motionController},
statusIcons(batteryController, bleController) { statusIcons(batteryController, bleController) {
@ -35,18 +35,14 @@ WatchFaceFuzzy::WatchFaceFuzzy(Controllers::DateTime& dateTimeController,
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); 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); 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_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));
label_time_ampm = lv_label_create(lv_scr_act(), nullptr); lv_obj_align(label_date, label_time, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_label_set_text_static(label_time_ampm, "");
lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55);
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat); lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
@ -91,43 +87,18 @@ void WatchFaceFuzzy::Refresh() {
uint8_t hour = dateTimeController.Hours(); uint8_t hour = dateTimeController.Hours();
uint8_t minute = dateTimeController.Minutes(); uint8_t minute = dateTimeController.Minutes();
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { printTimeWords(static_cast<int>(hour), static_cast<int>(minute));
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);
}
currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get()); currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
if (currentDate.IsUpdated()) { if (currentDate.IsUpdated()) {
uint16_t year = dateTimeController.Year(); uint16_t year = dateTimeController.Year();
uint8_t day = dateTimeController.Day(); uint8_t day = dateTimeController.Day();
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
lv_label_set_text_fmt(label_date, lv_label_set_text_fmt(label_date,
"%s %d %s %d", "%s %d %s %d",
dateTimeController.DayOfWeekShortToString(), dateTimeController.DayOfWeekShortToString(),
day, day,
dateTimeController.MonthShortToString(), dateTimeController.MonthShortToString(),
year); year);
} else {
lv_label_set_text_fmt(label_date,
"%s %s %d %d",
dateTimeController.DayOfWeekShortToString(),
dateTimeController.MonthShortToString(),
day,
year);
}
lv_obj_realign(label_date); lv_obj_realign(label_date);
} }
} }
@ -154,3 +125,31 @@ void WatchFaceFuzzy::Refresh() {
lv_obj_realign(stepIcon); 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);
}

View File

@ -12,7 +12,6 @@
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {
class Settings;
class Battery; class Battery;
class Ble; class Ble;
class NotificationManager; class NotificationManager;
@ -29,7 +28,6 @@ namespace Pinetime {
const Controllers::Battery& batteryController, const Controllers::Battery& batteryController,
const Controllers::Ble& bleController, const Controllers::Ble& bleController,
Controllers::NotificationManager& notificationManager, Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController, Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController); Controllers::MotionController& motionController);
~WatchFaceFuzzy() override; ~WatchFaceFuzzy() override;
@ -40,6 +38,11 @@ namespace Pinetime {
uint8_t displayedHour = -1; uint8_t displayedHour = -1;
uint8_t displayedMinute = -1; uint8_t displayedMinute = -1;
static char const *nums[];
static char const *mods[];
char timeStr[64];
Utility::DirtyValue<uint8_t> batteryPercentRemaining {}; Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
Utility::DirtyValue<bool> powerPresent {}; Utility::DirtyValue<bool> powerPresent {};
Utility::DirtyValue<bool> bleState {}; Utility::DirtyValue<bool> bleState {};
@ -53,7 +56,6 @@ namespace Pinetime {
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, days>> currentDate; Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, days>> currentDate;
lv_obj_t* label_time; lv_obj_t* label_time;
lv_obj_t* label_time_ampm;
lv_obj_t* label_date; lv_obj_t* label_date;
lv_obj_t* heartbeatIcon; lv_obj_t* heartbeatIcon;
lv_obj_t* heartbeatValue; lv_obj_t* heartbeatValue;
@ -63,12 +65,13 @@ namespace Pinetime {
Controllers::DateTime& dateTimeController; Controllers::DateTime& dateTimeController;
Controllers::NotificationManager& notificationManager; Controllers::NotificationManager& notificationManager;
Controllers::Settings& settingsController;
Controllers::HeartRateController& heartRateController; Controllers::HeartRateController& heartRateController;
Controllers::MotionController& motionController; Controllers::MotionController& motionController;
lv_task_t* taskRefresh; lv_task_t* taskRefresh;
Widgets::StatusIcons statusIcons; Widgets::StatusIcons statusIcons;
void printTimeWords(int h, int m);
}; };
} }
} }

View File

@ -9,7 +9,6 @@
#include "displayapp/screens/Screen.h" #include "displayapp/screens/Screen.h"
#include "displayapp/screens/Symbols.h" #include "displayapp/screens/Symbols.h"
#include "displayapp/screens/CheckboxList.h" #include "displayapp/screens/CheckboxList.h"
#include "displayapp/screens/WatchFaceInfineat.h"
#include "displayapp/screens/WatchFaceCasioStyleG7710.h" #include "displayapp/screens/WatchFaceCasioStyleG7710.h"
#include "displayapp/screens/WatchFaceFuzzy.h" #include "displayapp/screens/WatchFaceFuzzy.h"