From 63493078ef20419f4ebdfe74e5587176dc0fb1be Mon Sep 17 00:00:00 2001 From: Julian Foad Date: Tue, 7 May 2024 14:07:25 +0100 Subject: [PATCH] show owner name (on Analog, Digital, Terminal) --- src/displayapp/apps/Apps.h.in | 6 ++++++ src/displayapp/apps/CMakeLists.txt | 5 +++++ src/displayapp/screens/WatchFaceAnalog.cpp | 7 +++++++ src/displayapp/screens/WatchFaceAnalog.h | 2 ++ src/displayapp/screens/WatchFaceDigital.cpp | 7 +++++++ src/displayapp/screens/WatchFaceDigital.h | 2 ++ src/displayapp/screens/WatchFaceTerminal.cpp | 4 ++-- 7 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/displayapp/apps/Apps.h.in b/src/displayapp/apps/Apps.h.in index 2104a267..6b4a8b1c 100644 --- a/src/displayapp/apps/Apps.h.in +++ b/src/displayapp/apps/Apps.h.in @@ -75,5 +75,11 @@ namespace Pinetime { using UserWatchFaceTypes = WatchFaceTypeList<@WATCHFACE_TYPES@>; static_assert(UserWatchFaceTypes::Count >= 1); + + // a label such as the owner's name + // up to 20 characters (fits screen width in default font) + static const char OwnerText[] = "@OWNER_TEXT@"; + // up to 6 characters (fits username in "Terminal" watch face in default font) + static const char OwnerTextShort[] = "@OWNER_TEXT_SHORT@"; } } diff --git a/src/displayapp/apps/CMakeLists.txt b/src/displayapp/apps/CMakeLists.txt index d7858760..f1b7e884 100644 --- a/src/displayapp/apps/CMakeLists.txt +++ b/src/displayapp/apps/CMakeLists.txt @@ -30,6 +30,11 @@ else() set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware") endif() +# Owner text displayed on watch faces, <=20ch +set(OWNER_TEXT "Pine Time") +# Owner text displayed on watch faces, <=6ch +set(OWNER_TEXT_SHORT "pine") + add_library(infinitime_apps INTERFACE) target_sources(infinitime_apps INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/Apps.h") target_include_directories(infinitime_apps INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/") diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 80a1c8b9..e74c441b 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -110,6 +110,13 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); + // Owner's text + label_owner = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(label_owner, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xFF, 0xAE, 0xC9)); + lv_label_set_text_static(label_owner, Pinetime::Applications::OwnerText); + lv_label_set_align(label_owner, LV_LABEL_ALIGN_CENTER); + lv_obj_align(label_owner, nullptr, LV_ALIGN_CENTER, 0, 50); + // Date - Day / Week day label_date_day = lv_label_create(lv_scr_act(), nullptr); diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h index 958ff64d..bc37510a 100644 --- a/src/displayapp/screens/WatchFaceAnalog.h +++ b/src/displayapp/screens/WatchFaceAnalog.h @@ -68,6 +68,8 @@ namespace Pinetime { lv_style_t minute_line_style_trace; lv_style_t second_line_style; + lv_obj_t* label_owner; + lv_obj_t* label_date_day; lv_obj_t* plugIcon; lv_obj_t* notificationIcon; diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index d944117d..464669cb 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -35,6 +35,13 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController, statusIcons.Create(); + // Owner's text + label_owner = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(label_owner, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xFF, 0xAE, 0xC9)); + lv_label_set_text_static(label_owner, Pinetime::Applications::OwnerText); + lv_label_set_align(label_owner, LV_LABEL_ALIGN_CENTER); + lv_obj_align(label_owner, nullptr, LV_ALIGN_CENTER, 0, -80); + 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)); diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index 7bb713cb..38851dea 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -52,6 +52,8 @@ namespace Pinetime { Utility::DirtyValue> currentDate; + lv_obj_t* label_owner; + lv_obj_t* label_time; lv_obj_t* label_time_ampm; lv_obj_t* label_date; diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp index 96d77741..f470b440 100644 --- a/src/displayapp/screens/WatchFaceTerminal.cpp +++ b/src/displayapp/screens/WatchFaceTerminal.cpp @@ -44,11 +44,11 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController, label_prompt_1 = lv_label_create(lv_scr_act(), nullptr); lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80); - lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now"); + lv_label_set_text_fmt(label_prompt_1, "%s@watch:~ $ now", Pinetime::Applications::OwnerTextShort); label_prompt_2 = lv_label_create(lv_scr_act(), nullptr); lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60); - lv_label_set_text_static(label_prompt_2, "user@watch:~ $"); + lv_label_set_text_fmt(label_prompt_2, "%s@watch:~ $", Pinetime::Applications::OwnerTextShort); label_time = lv_label_create(lv_scr_act(), nullptr); lv_label_set_recolor(label_time, true);