fuzzy clock
This commit is contained in:
parent
3ade3153e5
commit
deb8f9368f
|
@ -2,76 +2,79 @@
|
||||||
"jetbrains_mono_bold_20": {
|
"jetbrains_mono_bold_20": {
|
||||||
"sources": [
|
"sources": [
|
||||||
{
|
{
|
||||||
"file": "JetBrainsMono-Bold.ttf",
|
"file": "Vulf_Mono-Italic.woff",
|
||||||
"range": "0x20-0x7e, 0x410-0x44f, 0xB0"
|
"range": "0x20-0x7e, 0xB0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
"file": "JetBrainsMono-Bold.ttf",
|
||||||
"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"
|
"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,
|
"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": [
|
||||||
{
|
{
|
||||||
"file": "JetBrainsMono-Regular.ttf",
|
"file": "JetBrainsMono-Regular.ttf",
|
||||||
"range": "0x25, 0x2b, 0x2d, 0x30-0x3a"
|
"range": "0x25, 0x2b, 0x2d, 0x30-0x3a"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bpp": 1,
|
"bpp": 1,
|
||||||
"size": 42
|
"size": 42
|
||||||
},
|
},
|
||||||
"jetbrains_mono_76": {
|
"jetbrains_mono_76": {
|
||||||
"sources": [
|
"sources": [
|
||||||
{
|
{
|
||||||
"file": "JetBrainsMono-Light.ttf",
|
"file": "JetBrainsMono-Light.ttf",
|
||||||
"range": "0x25, 0x2D, 0x2F, 0x30-0x3a"
|
"range": "0x25, 0x2D, 0x2F, 0x30-0x3a"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bpp": 1,
|
"bpp": 1,
|
||||||
"size": 76
|
"size": 76
|
||||||
},
|
},
|
||||||
"jetbrains_mono_extrabold_compressed": {
|
"jetbrains_mono_extrabold_compressed": {
|
||||||
"sources": [
|
"sources": [
|
||||||
{
|
{
|
||||||
"file": "JetBrainsMono-ExtraBold.ttf",
|
"file": "JetBrainsMono-ExtraBold.ttf",
|
||||||
"range": "0x30-0x3a"
|
"range": "0x20, 0x30-0x3a"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bpp": 1,
|
"bpp": 1,
|
||||||
"size": 80
|
"size": 80
|
||||||
},
|
},
|
||||||
"open_sans_light": {
|
"open_sans_light": {
|
||||||
"sources": [
|
"sources": [
|
||||||
{
|
{
|
||||||
"file": "open_sans_light.ttf",
|
"file": "open_sans_light.ttf",
|
||||||
"symbols": "0123456789"
|
"symbols": "0123456789"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bpp": 1,
|
"bpp": 1,
|
||||||
"size": 150
|
"size": 150
|
||||||
},
|
},
|
||||||
"lv_font_sys_48": {
|
"lv_font_sys_48": {
|
||||||
"sources": [
|
"sources": [
|
||||||
{
|
{
|
||||||
"file": "material-design-icons/MaterialIcons-Regular.ttf",
|
"file": "material-design-icons/MaterialIcons-Regular.ttf",
|
||||||
"range": "0xf00b, 0xe3aa-0xe3ac, 0xe7f6-0xe7f7, 0xe8b8, 0xef44, 0xe40a"
|
"range": "0xf00b, 0xe3aa-0xe3ac, 0xe7f6-0xe7f7, 0xe8b8, 0xef44, 0xe40a"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bpp": 1,
|
"bpp": 1,
|
||||||
"size": 48
|
"size": 48
|
||||||
},
|
},
|
||||||
"fontawesome_weathericons": {
|
"fontawesome_weathericons": {
|
||||||
"sources": [
|
"sources": [
|
||||||
{
|
{
|
||||||
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
||||||
"range": "0xf185, 0xf6c4, 0xf743, 0xf740, 0xf75f, 0xf0c2, 0xf05e"
|
"range": "0xf185, 0xf6c4, 0xf743, 0xf740, 0xf75f, 0xf0c2, 0xf05e"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bpp": 1,
|
"bpp": 1,
|
||||||
"size": 25
|
"size": 25
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,6 @@ std::unique_ptr<Screen> Clock::WatchFaceFuzzy() {
|
||||||
batteryController,
|
batteryController,
|
||||||
bleController,
|
bleController,
|
||||||
notificationManager,
|
notificationManager,
|
||||||
settingsController,
|
|
||||||
heartRateController,
|
heartRateController,
|
||||||
motionController);
|
motionController);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
|
@ -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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user