Add fonts, remove Digital

This commit is contained in:
Will Bradley 2024-01-16 18:58:06 -08:00
parent cf4f54dc87
commit 5510bfe499
Signed by: will
GPG Key ID: 1159B930701263F3
16 changed files with 97 additions and 399 deletions

View File

@ -94,6 +94,9 @@ jobs:
- name: Remove Terminal from InfiniSim - name: Remove Terminal from InfiniSim
run: patch -i docker/infinisim-terminal.patch InfiniSim/littlefs-do-main.cpp run: patch -i docker/infinisim-terminal.patch InfiniSim/littlefs-do-main.cpp
- name: Remove Digital from InfiniSim
run: patch -i docker/infinisim-main.patch InfiniSim/main.cpp
- name: CMake - name: CMake
# disable BUILD_RESOURCES as this is already done when building the firmware # disable BUILD_RESOURCES as this is already done when building the firmware
run: | run: |

View File

@ -0,0 +1,20 @@
diff --git a/main.cpp b/main.cpp
index 8070db7..530ff4b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -823,14 +823,10 @@ public:
void switch_to_screen(uint8_t screen_idx)
{
if (screen_idx == 1) {
- settingsController.SetWatchFace(Pinetime::Applications::WatchFace::Digital);
- displayApp.StartApp(Pinetime::Applications::Apps::Clock, Pinetime::Applications::DisplayApp::FullRefreshDirections::None);
- }
- else if (screen_idx == 2) {
settingsController.SetWatchFace(Pinetime::Applications::WatchFace::Analog);
displayApp.StartApp(Pinetime::Applications::Apps::Clock, Pinetime::Applications::DisplayApp::FullRefreshDirections::None);
}
- else if (screen_idx == 3) {
+ else if (screen_idx == 2) {
settingsController.SetWatchFace(Pinetime::Applications::WatchFace::PineTimeStyle);
displayApp.StartApp(Pinetime::Applications::Apps::Clock, Pinetime::Applications::DisplayApp::FullRefreshDirections::None);
}

View File

@ -1,9 +1,13 @@
diff --git a/littlefs-do-main.cpp b/littlefs-do-main.cpp diff --git a/littlefs-do-main.cpp b/littlefs-do-main.cpp
index 0a5dfbd..5d902f8 100644 index 0a5dfbd..3e818af 100644
--- a/littlefs-do-main.cpp --- a/littlefs-do-main.cpp
+++ b/littlefs-do-main.cpp +++ b/littlefs-do-main.cpp
@@ -540,7 +540,7 @@ int command_settings(const std::string &program_name, const std::vector<std::str @@ -537,10 +537,10 @@ int command_settings(const std::string &program_name, const std::vector<std::str
if (val == Pinetime::Applications::WatchFace::Digital) return "Digital"; {
auto clockface = settingsController.GetWatchFace();
auto clockface_str = [](auto val) {
- if (val == Pinetime::Applications::WatchFace::Digital) return "Digital";
+ //if (val == Pinetime::Applications::WatchFace::Digital) return "Digital";
if (val == Pinetime::Applications::WatchFace::Analog) return "Analog"; if (val == Pinetime::Applications::WatchFace::Analog) return "Analog";
if (val == Pinetime::Applications::WatchFace::PineTimeStyle) return "PineTimeStyle"; if (val == Pinetime::Applications::WatchFace::PineTimeStyle) return "PineTimeStyle";
- if (val == Pinetime::Applications::WatchFace::Terminal) return "Terminal"; - if (val == Pinetime::Applications::WatchFace::Terminal) return "Terminal";

View File

@ -424,7 +424,7 @@ list(APPEND SOURCE_FILES
## Watch faces ## Watch faces
displayapp/screens/WatchFaceAnalog.cpp displayapp/screens/WatchFaceAnalog.cpp
displayapp/screens/WatchFaceDigital.cpp #displayapp/screens/WatchFaceDigital.cpp
#displayapp/screens/WatchFaceInfineat.cpp #displayapp/screens/WatchFaceInfineat.cpp
#displayapp/screens/WatchFaceTerminal.cpp #displayapp/screens/WatchFaceTerminal.cpp
displayapp/screens/WatchFacePineTimeStyle.cpp displayapp/screens/WatchFacePineTimeStyle.cpp

View File

@ -318,7 +318,7 @@ namespace Pinetime {
WeatherFormat weatherFormat = WeatherFormat::Metric; WeatherFormat weatherFormat = WeatherFormat::Metric;
Notification notificationStatus = Notification::On; Notification notificationStatus = Notification::On;
Pinetime::Applications::WatchFace watchFace = Pinetime::Applications::WatchFace::Digital; Pinetime::Applications::WatchFace watchFace = Pinetime::Applications::WatchFace::Analog; //Digital
ChimesOption chimesOption = ChimesOption::None; ChimesOption chimesOption = ChimesOption::None;
PineTimeStyle PTS; PineTimeStyle PTS;

View File

@ -7,7 +7,7 @@
#include "displayapp/screens/Twos.h" #include "displayapp/screens/Twos.h"
#include "displayapp/screens/Tile.h" #include "displayapp/screens/Tile.h"
#include "displayapp/screens/ApplicationList.h" #include "displayapp/screens/ApplicationList.h"
#include "displayapp/screens/WatchFaceDigital.h" //#include "displayapp/screens/WatchFaceDigital.h"
#include "displayapp/screens/WatchFaceAnalog.h" #include "displayapp/screens/WatchFaceAnalog.h"
// #include "displayapp/screens/WatchFaceCasioStyleG7710.h" // #include "displayapp/screens/WatchFaceCasioStyleG7710.h"
// #include "displayapp/screens/WatchFaceInfineat.h" // #include "displayapp/screens/WatchFaceInfineat.h"

View File

@ -46,7 +46,6 @@ namespace Pinetime {
}; };
enum class WatchFace : uint8_t { enum class WatchFace : uint8_t {
Digital,
Analog, Analog,
PineTimeStyle, PineTimeStyle,
}; };
@ -69,8 +68,7 @@ namespace Pinetime {
static constexpr size_t Count = sizeof...(Ws); static constexpr size_t Count = sizeof...(Ws);
}; };
using UserWatchFaceTypes = WatchFaceTypeList<WatchFace::Digital, using UserWatchFaceTypes = WatchFaceTypeList<WatchFace::Analog,
WatchFace::Analog,
WatchFace::PineTimeStyle>; WatchFace::PineTimeStyle>;
static_assert(UserWatchFaceTypes::Count >= 1); static_assert(UserWatchFaceTypes::Count >= 1);

View File

@ -1,9 +1,10 @@
if(DEFINED ENABLE_USERAPPS) #if(DEFINED ENABLE_USERAPPS)
set(USERAPP_TYPES ${ENABLE_USERAPPS} CACHE STRING "List of user apps to build into the firmware") # set(USERAPP_TYPES ${ENABLE_USERAPPS} CACHE STRING "List of user apps to build into the firmware")
else () #else ()
set(USERAPP_TYPES "Apps::Navigation, Apps::Alarm, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Twos" CACHE STRING "List of user apps to build into the firmware") set(USERAPP_TYPES "Apps::Timer" CACHE STRING "List of user apps to build into the firmware")
#Apps::Paint, Apps::Metronome, Apps::Paddle, Apps::StopWatch, Apps::Timer, #Apps::Paint, Apps::Metronome, Apps::Paddle, Apps::StopWatch, Apps::Timer,
endif () #Apps::Navigation, Apps::Alarm, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Twos
#endif ()
add_library(infinitime_apps INTERFACE) add_library(infinitime_apps INTERFACE)
target_sources(infinitime_apps INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/Apps.h") target_sources(infinitime_apps INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/Apps.h")

View File

@ -1,4 +1,4 @@
set(FONTS jetbrains_mono_42 jetbrains_mono_76 jetbrains_mono_bold_20 set(FONTS jetbrains_mono_42 noto_serif_cjk_20 noto_serif_cjk_15 jetbrains_mono_76 jetbrains_mono_bold_20
jetbrains_mono_extrabold_compressed lv_font_sys_48 jetbrains_mono_extrabold_compressed lv_font_sys_48
open_sans_light fontawesome_weathericons) open_sans_light fontawesome_weathericons)
find_program(LV_FONT_CONV "lv_font_conv" NO_CACHE REQUIRED find_program(LV_FONT_CONV "lv_font_conv" NO_CACHE REQUIRED

Binary file not shown.

View File

@ -14,6 +14,26 @@
"size": 20, "size": 20,
"patches": ["jetbrains_mono_bold_20.c_zero.patch", "jetbrains_mono_bold_20.c_M.patch"] "patches": ["jetbrains_mono_bold_20.c_zero.patch", "jetbrains_mono_bold_20.c_M.patch"]
}, },
"noto_serif_cjk_20": {
"sources": [
{
"file": "NotoSerifCJKjp-VF.ttf",
"symbols": "丑寅卯辰巳午未申酉戌亥子四五六七八九"
}
],
"bpp": 1,
"size": 20
},
"noto_serif_cjk_15": {
"sources": [
{
"file": "NotoSerifCJKjp-VF.ttf",
"symbols": "四五六七八九"
}
],
"bpp": 1,
"size": 15
},
"jetbrains_mono_42": { "jetbrains_mono_42": {
"sources": [ "sources": [
{ {

View File

@ -44,6 +44,22 @@ namespace {
.y = CoordinateYRelocate(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE)}; .y = CoordinateYRelocate(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE)};
} }
void printKoku(const char* str, uint8_t i, bool big){
lv_obj_t* koku = lv_label_create(lv_scr_act(), NULL);
lv_label_set_align(koku, LV_LABEL_ALIGN_CENTER);
lv_label_set_text(koku, str);
lv_point_t pt;
if (big) {
pt = CoordinateRelocate(LV_HOR_RES/2-20, i*30);
lv_obj_set_style_local_text_font(koku, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &noto_serif_cjk_20);
} else {
pt = CoordinateRelocate(LV_HOR_RES/2-45, i*30);
lv_obj_set_style_local_text_font(koku, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &noto_serif_cjk_15);
}
lv_obj_align(koku, NULL, LV_ALIGN_CENTER, LV_HOR_RES/2-pt.x-10, LV_HOR_RES/2-pt.y);
lv_obj_set_style_local_text_color(koku, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
}
} }
WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
@ -73,27 +89,24 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
lv_obj_set_size(major_scales, 240, 240); lv_obj_set_size(major_scales, 240, 240);
lv_obj_align(major_scales, nullptr, LV_ALIGN_CENTER, 0, 0); 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_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, 40); lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 60);
lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 1); lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 1);
lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
axis = lv_arc_create(lv_scr_act(), NULL); axis = lv_arc_create(lv_scr_act(), NULL);
lv_obj_set_size(axis, 40, 40); lv_obj_set_size(axis, 40, 40);
lv_arc_set_bg_angles(axis, 0, 360); lv_arc_set_bg_angles(axis, 0, 360);
lv_arc_set_end_angle(axis, 360);
lv_obj_align(axis, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_align(axis, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_local_bg_color(axis, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_obj_set_style_local_line_color(axis, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_WHITE);
one = lv_label_create(lv_scr_act(), NULL); const char* kokuZodiac[] = {"","","","","","","","","","","",""};
lv_label_set_align(one, LV_LABEL_ALIGN_LEFT); const char* kokuNums[] = {"","","","","",""};
lv_label_set_text(one, "I");
lv_obj_align(one, NULL, LV_ALIGN_IN_TOP_LEFT, 20, 0);
lv_obj_set_style_local_text_color(one, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
twelve = lv_label_create(lv_scr_act(), NULL); for (int i=0;i<12;i++) {
lv_label_set_align(twelve, LV_LABEL_ALIGN_RIGHT); printKoku(kokuZodiac[i], i, true);
lv_label_set_text(twelve, "XII"); printKoku(kokuNums[i%6], i, false);
lv_obj_align(twelve, NULL, LV_ALIGN_IN_TOP_RIGHT, -20, 0); }
lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
} else { } else {
minor_scales = lv_linemeter_create(lv_scr_act(), nullptr); minor_scales = lv_linemeter_create(lv_scr_act(), nullptr);
lv_linemeter_set_scale(minor_scales, 300, 51); lv_linemeter_set_scale(minor_scales, 300, 51);
@ -258,14 +271,19 @@ void WatchFaceAnalog::drawWatchFaceWadokei(){
sHour = hour; sHour = hour;
sMinute = minute; sMinute = minute;
hour_point_trace[0] = CoordinateRelocate(HourLength*.75, angle); // hour_point_trace[0] = CoordinateRelocate(HourLength*.75, angle);
hour_point_trace[1] = CoordinateRelocate(HourLength, angle); // hour_point_trace[1] = CoordinateRelocate(HourLength, angle);
hour_point[0] = CoordinateRelocate(0, angle); hour_point[0] = CoordinateRelocate(0, angle);
hour_point[1] = CoordinateRelocate(HourLength*.75, angle); hour_point[1] = CoordinateRelocate(HourLength*.75, angle);
lv_line_set_points(hour_body, hour_point, 2); 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);
lv_label_set_align(twelve, LV_LABEL_ALIGN_CENTER);
lv_label_set_text_fmt(twelve, "%2d:%02d", hour, minute);
lv_obj_set_pos(twelve, 0, 0);
lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
} }
} }
@ -370,7 +388,7 @@ void WatchFaceAnalog::Refresh() {
DaysString[static_cast<uint8_t>(dateTimeController.DayOfWeek())], DaysString[static_cast<uint8_t>(dateTimeController.DayOfWeek())],
RomanNumeralsString[static_cast<uint8_t>(dateTimeController.Day())], RomanNumeralsString[static_cast<uint8_t>(dateTimeController.Day())],
MonthsString[static_cast<uint8_t>(dateTimeController.Month())]); MonthsString[static_cast<uint8_t>(dateTimeController.Month())]);
lv_obj_align(label_date_day, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, -20); lv_obj_align(label_date_day, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, -2000);
} else { } else {
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
} }

View File

@ -1,228 +0,0 @@
#include "displayapp/screens/WatchFaceDigital.h"
#include <lvgl/lvgl.h>
#include <cstdio>
#include "displayapp/screens/NotificationIcon.h"
#include "displayapp/screens/Symbols.h"
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#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;
WatchFaceDigital::WatchFaceDigital(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) {
sHour = 99;
sMinute = 99;
statusIcons.Create();
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);
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 = lv_label_create(lv_scr_act(), nullptr);
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);
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
lv_label_set_text_static(heartbeatValue, "");
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
lv_label_set_text_static(stepValue, "0");
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
stepIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
lv_label_set_text_static(stepIcon, Symbols::shoe);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Refresh();
}
WatchFaceDigital::~WatchFaceDigital() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
void WatchFaceDigital::Refresh() {
statusIcons.Update();
notificationState = notificationManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
}
currentDateTime = dateTimeController.CurrentDateTime();
if (currentDateTime.IsUpdated()) {
uint8_t hour = dateTimeController.Hours();
uint8_t minute = dateTimeController.Minutes();
if (sHour != hour || sMinute != minute || forceRefresh == true) {
forceRefresh = false;
sHour = hour;
sMinute = minute;
if (settingsController.GetClockType() == Controllers::Settings::ClockType::Fuzzy) {
printTimeWords(static_cast<int>(hour), static_cast<int>(minute));
lv_label_set_text(label_time_ampm, "");
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -10);
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_recolor(label_time, true);
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
} else 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);
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed);
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
} 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);
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed);
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
}
lv_obj_realign(label_time);
lv_obj_realign(label_date);
}
currentDate = std::chrono::time_point_cast<days>(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_obj_realign(label_date);
}
}
heartbeat = heartRateController.HeartRate();
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
if (heartbeatRunning.Get()) {
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get());
} else {
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B));
lv_label_set_text_static(heartbeatValue, "");
}
lv_obj_realign(heartbeatIcon);
lv_obj_realign(heartbeatValue);
}
stepCount = motionController.NbSteps();
if (stepCount.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
lv_obj_realign(stepValue);
lv_obj_realign(stepIcon);
}
}
bool WatchFaceDigital::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
if ((event == Pinetime::Applications::TouchEvents::LongTap)) {
Pinetime::Controllers::Settings::ClockType clockType = settingsController.GetClockType();
if (clockType == Pinetime::Controllers::Settings::ClockType::Fuzzy) {
settingsController.SetClockType(Pinetime::Controllers::Settings::ClockType::H12);
} else {
settingsController.SetClockType(Pinetime::Controllers::Settings::ClockType::Fuzzy);
}
settingsController.SaveSettings();
forceRefresh=true;
WatchFaceDigital::Refresh();
return true;
}
return false;
}
char const* twelve = "twelve";
void WatchFaceDigital::printTimeWords(int h, int m) {
const char* mod;
char const* accent = "#808080";
char const* color = "#ffffff";
char const* oclock = "o' clock";
char const* past = "past";
char const* to = "to";
char const* hash = "#";
char const* nearly = "nearly";
char const* fmt = "%s %s%s\n%s %s%s %s %s%s";
if (m <= 30) {
mod = mods[m / 5];
} else {
mod = mods[(60-m) / 5];
}
h = (h % 12);
if (m >= 56) {
lv_label_set_text_fmt(label_time, "%s %s %s%s\n%s %s%s", color, nearly, nums[(h+1) % 12], hash, accent, oclock, hash);
}
else if (m == 0 || m <= 4) {
lv_label_set_text_fmt(label_time, "%s %s%s\n%s %s%s", color, nums[h], hash, accent, oclock, hash);
}
else if (m <= 32) {
lv_label_set_text_fmt(label_time, fmt, color, mod, hash, accent, past, hash, color, nums[h], hash);
}
else if (m > 32) {
lv_label_set_text_fmt(label_time, fmt, color, mod, hash, accent, to, hash, color, nums[(h+1) % 12], hash);
}
}

View File

@ -1,104 +0,0 @@
#pragma once
#include <lvgl/src/lv_core/lv_obj.h>
#include <chrono>
#include <cstdint>
#include <memory>
#include "displayapp/screens/Screen.h"
#include "components/datetime/DateTimeController.h"
#include "components/ble/BleController.h"
#include "displayapp/widgets/StatusIcons.h"
#include "utility/DirtyValue.h"
#include "displayapp/apps/Apps.h"
namespace Pinetime {
namespace Controllers {
class Settings;
class Battery;
class Ble;
class NotificationManager;
class HeartRateController;
class MotionController;
}
namespace Applications {
namespace Screens {
class WatchFaceDigital : public Screen {
public:
WatchFaceDigital(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController,
const Controllers::Ble& bleController,
Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController);
~WatchFaceDigital() override;
bool OnTouchEvent(TouchEvents event) override;
void Refresh() override;
private:
uint8_t sHour, sMinute;
uint8_t displayedHour = -1;
uint8_t displayedMinute = -1;
char const* mods[7] = {"", "five", "ten", "quarter", "twenty", "twenty five", "half"};
char const* nums[13] = {"twelve", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve"};
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
Utility::DirtyValue<bool> powerPresent {};
Utility::DirtyValue<bool> bleState {};
Utility::DirtyValue<bool> bleRadioEnabled {};
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
Utility::DirtyValue<uint32_t> stepCount {};
Utility::DirtyValue<uint8_t> heartbeat {};
Utility::DirtyValue<bool> heartbeatRunning {};
Utility::DirtyValue<bool> notificationState {};
using days = std::chrono::duration<int32_t, std::ratio<86400>>; // TODO: days is standard in c++20
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, days>> 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;
lv_obj_t* stepIcon;
lv_obj_t* stepValue;
lv_obj_t* notificationIcon;
Controllers::DateTime& dateTimeController;
Controllers::NotificationManager& notificationManager;
Controllers::Settings& settingsController;
Controllers::HeartRateController& heartRateController;
Controllers::MotionController& motionController;
lv_task_t* taskRefresh;
bool forceRefresh=false;
Widgets::StatusIcons statusIcons;
void printTimeWords(int h, int m);
};
}
template <>
struct WatchFaceTraits<WatchFace::Digital> {
static constexpr WatchFace watchFace = WatchFace::Digital;
static constexpr const char* name = "Digital face";
static Screens::Screen* Create(AppControllers& controllers) {
return new Screens::WatchFaceDigital(controllers.dateTimeController,
controllers.batteryController,
controllers.bleController,
controllers.notificationManager,
controllers.settingsController,
controllers.heartRateController,
controllers.motionController);
};
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
return true;
}
};
}
}

View File

@ -417,6 +417,8 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in
LV_FONT_DECLARE(jetbrains_mono_extrabold_compressed) \ LV_FONT_DECLARE(jetbrains_mono_extrabold_compressed) \
LV_FONT_DECLARE(jetbrains_mono_42) \ LV_FONT_DECLARE(jetbrains_mono_42) \
LV_FONT_DECLARE(jetbrains_mono_76) \ LV_FONT_DECLARE(jetbrains_mono_76) \
LV_FONT_DECLARE(noto_serif_cjk_20) \
LV_FONT_DECLARE(noto_serif_cjk_15) \
LV_FONT_DECLARE(open_sans_light) \ LV_FONT_DECLARE(open_sans_light) \
LV_FONT_DECLARE(fontawesome_weathericons) \ LV_FONT_DECLARE(fontawesome_weathericons) \
LV_FONT_DECLARE(lv_font_sys_48) LV_FONT_DECLARE(lv_font_sys_48)

View File

@ -22,41 +22,5 @@
"size": 120, "size": 120,
"format": "bin", "format": "bin",
"target_path": "/fonts/" "target_path": "/fonts/"
},
"lv_font_dots_40": {
"sources": [
{
"file": "fonts/repetitionscrolling.ttf",
"symbols": "0123456789-MONTUEWEDTHUFRISATSUN WK"
}
],
"bpp": 1,
"size": 40,
"format": "bin",
"target_path": "/fonts/"
},
"7segments_40" : {
"sources": [
{
"file": "fonts/7segment.woff",
"symbols": "0123456789: -"
}
],
"bpp": 1,
"size": 40,
"format": "bin",
"target_path": "/fonts/"
},
"7segments_115" : {
"sources": [
{
"file": "fonts/7segment.woff",
"symbols": "0123456789: -"
}
],
"bpp": 1,
"size": 115,
"format": "bin",
"target_path": "/fonts/"
} }
} }