diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0a97a0158b..1710ff2b3b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -423,6 +423,7 @@ list(APPEND SOURCE_FILES displayapp/screens/WatchFaceAnalog.cpp displayapp/screens/WatchFaceDigital.cpp displayapp/screens/WatchFaceInfineat.cpp + displayapp/screens/WatchFaceLCARS.cpp displayapp/screens/WatchFaceTerminal.cpp displayapp/screens/WatchFacePineTimeStyle.cpp displayapp/screens/WatchFaceCasioStyleG7710.cpp diff --git a/src/displayapp/UserApps.h b/src/displayapp/UserApps.h index 67bbfa7d41..006cbdcb01 100644 --- a/src/displayapp/UserApps.h +++ b/src/displayapp/UserApps.h @@ -12,6 +12,7 @@ #include "displayapp/screens/WatchFaceAnalog.h" #include "displayapp/screens/WatchFaceCasioStyleG7710.h" #include "displayapp/screens/WatchFaceInfineat.h" +#include "displayapp/screens/WatchFaceLCARS.h" #include "displayapp/screens/WatchFacePineTimeStyle.h" #include "displayapp/screens/WatchFaceTerminal.h" diff --git a/src/displayapp/apps/Apps.h.in b/src/displayapp/apps/Apps.h.in index 2104a267c0..03685c5f88 100644 --- a/src/displayapp/apps/Apps.h.in +++ b/src/displayapp/apps/Apps.h.in @@ -51,6 +51,7 @@ namespace Pinetime { PineTimeStyle, Terminal, Infineat, + LCARS, CasioStyleG7710, }; diff --git a/src/displayapp/apps/CMakeLists.txt b/src/displayapp/apps/CMakeLists.txt index d78587609e..e5a803e458 100644 --- a/src/displayapp/apps/CMakeLists.txt +++ b/src/displayapp/apps/CMakeLists.txt @@ -26,6 +26,7 @@ else() set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::PineTimeStyle") set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Terminal") set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Infineat") + set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::LCARS") set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::CasioStyleG7710") set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware") endif() diff --git a/src/displayapp/fonts/fonts.json b/src/displayapp/fonts/fonts.json index 41c383c0d4..7ce5cb74cf 100644 --- a/src/displayapp/fonts/fonts.json +++ b/src/displayapp/fonts/fonts.json @@ -7,7 +7,7 @@ }, { "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, 0xf0f3, 0xf522, 0xf743" + "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, 0xf0f3, 0xf522, 0xf743, 0xf0e0" } ], "bpp": 1, diff --git a/src/displayapp/screens/Symbols.h b/src/displayapp/screens/Symbols.h index bd958b285f..66f5164923 100644 --- a/src/displayapp/screens/Symbols.h +++ b/src/displayapp/screens/Symbols.h @@ -39,6 +39,7 @@ namespace Pinetime { static constexpr const char* eye = "\xEF\x81\xAE"; static constexpr const char* home = "\xEF\x80\x95"; static constexpr const char* sleep = "\xEE\xBD\x84"; + static constexpr const char* message = "\xEF\x83\xA0"; // fontawesome_weathericons.c // static constexpr const char* sun = "\xEF\x86\x85"; diff --git a/src/displayapp/screens/WatchFaceLCARS.cpp b/src/displayapp/screens/WatchFaceLCARS.cpp new file mode 100644 index 0000000000..ed40bc7b44 --- /dev/null +++ b/src/displayapp/screens/WatchFaceLCARS.cpp @@ -0,0 +1,341 @@ +#include "displayapp/screens/WatchFaceLCARS.h" + +#include +#include +#include "displayapp/screens/Symbols.h" +#include "displayapp/screens/BleIcon.h" +#include "components/settings/Settings.h" +#include "components/battery/BatteryController.h" +#include "components/heartrate/HeartRateController.h" +#include "components/ble/BleController.h" +#include "components/ble/NotificationManager.h" +#include "components/motion/MotionController.h" + +using namespace Pinetime::Applications::Screens; + +namespace { + void set_label_color(lv_obj_t* label, lv_color_t color) { + lv_obj_set_style_local_text_color(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color); + } + lv_obj_t* label_make(lv_obj_t* container, int16_t position_x, int16_t position_y, lv_color_t color, uint8_t align, const char* text) { + lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color); + lv_label_set_text_static(label, text); + lv_obj_align(label, container, align, position_x, position_y); + return label; + } + lv_obj_t* label_make_with_font(lv_obj_t* container, int16_t position_x, int16_t position_y, lv_color_t color, lv_font_t* font, uint8_t align, const char* text) { + lv_obj_t* label = label_make(container, position_x, position_y, color, align, text); + lv_obj_set_style_local_text_font(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font); + lv_obj_realign(label); + return label; + } + lv_obj_t* label_container_make(lv_obj_t* parent, int16_t position_x, int16_t position_y, uint8_t size_x, uint8_t size_y, uint8_t align) { + lv_obj_t* container = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_bg_opa(container, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); + lv_obj_set_size(container, size_x, size_y); + lv_obj_align(container, parent, align, position_x, position_y); + return container; + } +} + +WatchFaceLCARS::WatchFaceLCARS(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::MotionController& motionController, + Controllers::HeartRateController& heartRateController, + Controllers::FS& filesystem) + : currentDateTime {{}}, + currentNanoSeconds {{}}, + dateTimeController {dateTimeController}, + batteryController {batteryController}, + bleController {bleController}, + notificationManager {notificationManager}, + settingsController {settingsController}, + motionController {motionController}, + heartRateController {heartRateController} { + + // Fonts + lfs_file f = {}; + + if (filesystem.FileOpen(&f, "/fonts/antonio_78.bin", LFS_O_RDONLY) >= 0) { + filesystem.FileClose(&f); + font_antonio_78 = lv_font_load("F:/fonts/antonio_78.bin"); + } + if (filesystem.FileOpen(&f, "/fonts/antonio_33.bin", LFS_O_RDONLY) >= 0) { + filesystem.FileClose(&f); + font_antonio_33 = lv_font_load("F:/fonts/antonio_33.bin"); + } + if (filesystem.FileOpen(&f, "/fonts/antonio_21.bin", LFS_O_RDONLY) >= 0) { + filesystem.FileClose(&f); + font_antonio_21 = lv_font_load("F:/fonts/antonio_21.bin"); + } + if (filesystem.FileOpen(&f, "/fonts/antonio_13.bin", LFS_O_RDONLY) >= 0) { + filesystem.FileClose(&f); + font_antonio_13 = lv_font_load("F:/fonts/antonio_13.bin"); + } + + // Background + background = lv_img_create(lv_scr_act(), nullptr); + lv_img_set_src(background, "F:/images/LCARS.bin"); + lv_obj_set_pos(background, 0, 0); + + // System + system_container = label_container_make(lv_scr_act(), 0, 5, 170, 20, LV_ALIGN_IN_TOP_RIGHT); + labelBattery = label_make_with_font(system_container, 0, 0, grayColor, font_antonio_21, LV_ALIGN_IN_TOP_RIGHT, "0 %"); + bleIcon = label_make(labelBattery, -5, 0, orangeColor, LV_ALIGN_OUT_LEFT_MID, Symbols::bluetooth); + + // Date + dateContainer = label_container_make(lv_scr_act(), 65, 50, 175, 20, LV_ALIGN_IN_TOP_LEFT); + labelDate = label_make_with_font(dateContainer, 0, 0, orangeColor, font_antonio_21, LV_ALIGN_IN_LEFT_MID, "12024 MON 01 MAR"); + labelTimeAmPm = label_make_with_font(dateContainer, 0, 0, orangeColor, font_antonio_21, LV_ALIGN_IN_RIGHT_MID, ""); + + // Seconds Labels + label_seconds_container = label_container_make(lv_scr_act(), 65, 150, 90, 15, LV_ALIGN_IN_TOP_LEFT); + + label_tens_container = label_container_make(label_seconds_container, 0, 0, 90, 15, LV_ALIGN_IN_TOP_LEFT); + label_tens[0] = label_make_with_font(label_tens_container, 0, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "0"); + label_tens[1] = label_make_with_font(label_tens_container, 10, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "1"); + label_tens[2] = label_make_with_font(label_tens_container, 20, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "2"); + label_tens[3] = label_make_with_font(label_tens_container, 30, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "3"); + label_tens[4] = label_make_with_font(label_tens_container, 40, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "4"); + label_tens[5] = label_make_with_font(label_tens_container, 50, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "5"); + + label_ones_container = label_container_make(label_seconds_container, 0, 15, 90, 15, LV_ALIGN_IN_TOP_LEFT); + label_ones[0] = label_make_with_font(label_ones_container, 0, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "0"); + label_ones[1] = label_make_with_font(label_ones_container, 10, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "1"); + label_ones[2] = label_make_with_font(label_ones_container, 20, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "2"); + label_ones[3] = label_make_with_font(label_ones_container, 30, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "3"); + label_ones[4] = label_make_with_font(label_ones_container, 40, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "4"); + label_ones[5] = label_make_with_font(label_ones_container, 50, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "5"); + label_ones[6] = label_make_with_font(label_ones_container, 60, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "6"); + label_ones[7] = label_make_with_font(label_ones_container, 70, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "7"); + label_ones[8] = label_make_with_font(label_ones_container, 80, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "8"); + label_ones[9] = label_make_with_font(label_ones_container, 90, 0, grayColor, font_antonio_13, LV_ALIGN_IN_LEFT_MID, "9"); + + // Time + timeContainer = label_container_make(lv_scr_act(), 65, 76, 170, 60, LV_ALIGN_IN_TOP_LEFT); + labelTime = label_make_with_font(timeContainer, 0, 0, orangeColor, font_antonio_78, LV_ALIGN_IN_TOP_LEFT, "00:00"); + + // WK + label_week = label_make_with_font(lv_scr_act(), -5, 150, orangeColor, font_antonio_33, LV_ALIGN_IN_TOP_RIGHT, "WK00"); + + // Sensors + sensors_container = label_container_make(lv_scr_act(), 0, 0, 130, 50, LV_ALIGN_IN_BOTTOM_RIGHT); + stepValue = label_make_with_font(sensors_container, -5, 0, orangeColor, font_antonio_21, LV_ALIGN_IN_BOTTOM_RIGHT, "0"); + stepIcon = label_make(stepValue, -5, 0, orangeColor, LV_ALIGN_OUT_LEFT_MID, Symbols::shoe); + heartbeatValue = label_make_with_font(sensors_container, -5, -25, orangeColor, font_antonio_21, LV_ALIGN_IN_BOTTOM_RIGHT, "0"); + heartbeatIcon = label_make(heartbeatValue, -5, 0, orangeColor, LV_ALIGN_OUT_LEFT_MID, ""); + + // Tasks + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + Refresh(); +} + +WatchFaceLCARS::~WatchFaceLCARS() { + // Tasks + lv_task_del(taskRefresh); + + // Fonts + if (font_antonio_78 != nullptr) { + lv_font_free(font_antonio_78); + } + if (font_antonio_33 != nullptr) { + lv_font_free(font_antonio_33); + } + if (font_antonio_21 != nullptr) { + lv_font_free(font_antonio_21); + } + if (font_antonio_13 != nullptr) { + lv_font_free(font_antonio_13); + } + + // Objects + lv_obj_clean(lv_scr_act()); +} + +void WatchFaceLCARS::Refresh() { + currentNanoSeconds = std::chrono::time_point_cast(dateTimeController.CurrentDateTime()); + if (currentNanoSeconds.IsUpdated()) { + UpdateSeconds(); + UpdateStepCount(); + UpdateBatteryPercent(); + UpdateBLE(); + UpdateHeartRate(); + currentDateTime = std::chrono::time_point_cast(currentNanoSeconds.Get()); + if (currentDateTime.IsUpdated()) { + UpdateTime(); + currentDate = std::chrono::time_point_cast(currentDateTime.Get()); + if (currentDate.IsUpdated()) { + UpdateStardate(); + UpdateWK(); + } + } + } +} + +void WatchFaceLCARS::UpdateHeartRate() { + heartbeat = heartRateController.HeartRate(); + heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; + if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { + if (heartbeat.Get() > 120) { + set_label_color(heartbeatValue, redColor); + set_label_color(heartbeatIcon, redColor); + } else { + set_label_color(heartbeatValue, orangeColor); + set_label_color(heartbeatIcon, orangeColor); + } + if (heartbeatRunning.Get()) { + lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get()); + lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat); + } else { + lv_label_set_text_static(heartbeatValue, ""); + lv_label_set_text_static(heartbeatIcon, ""); + } + lv_obj_realign(heartbeatValue); + lv_obj_realign(heartbeatIcon); + } +} + +void WatchFaceLCARS::UpdateTime() { + 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(labelTimeAmPm, ampmChar); + weekNumberFormat = "%U"; + } else { + weekNumberFormat = "%V"; + } + lv_label_set_text_fmt(labelTime, "%2d:%02d", hour, minute); + + if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { + lv_obj_realign(labelTimeAmPm); + lv_obj_realign(labelTime); + } +} + +void WatchFaceLCARS::UpdateSeconds() { + uint8_t second = dateTimeController.Seconds(); + if (last_second != second) { + last_second = second; + ResetSecondsDigits(); + set_label_color(label_tens[second / 10], orangeColor); + set_label_color(label_ones[second % 10], orangeColor); + } +} + +void WatchFaceLCARS::UpdateWK() { + time_t ttTime = std::chrono::system_clock::to_time_t(std::chrono::time_point_cast(currentDate.Get())); + tm* tmTime = std::localtime(&ttTime); + char buffer[8]; + strftime(buffer, 8, weekNumberFormat, tmTime); + uint8_t weekNumber = atoi(buffer); + lv_label_set_text_fmt(label_week, "WK%02d", weekNumber); + lv_obj_realign(label_week); +} + +void WatchFaceLCARS::UpdateStardate() { + lv_label_set_text_fmt( + labelDate, + "1%d %s %d %s", + dateTimeController.Year(), + dateTimeController.DayOfWeekShortToString(), + dateTimeController.Day(), + dateTimeController.MonthShortToString() + ); + lv_obj_realign(labelDate); +} + +void WatchFaceLCARS::UpdateBatteryPercent() { + batteryPercentRemaining = batteryController.PercentRemaining(); + isCharging = batteryController.IsCharging(); + if (batteryController.IsCharging() ) { // Charging battery animation + chargingBatteryPercent += 1; + if (chargingBatteryPercent > 100) { + chargingBatteryPercent = batteryPercentRemaining.Get(); + } + if (chargingBatteryPercent <= 100 && ((chargingBatteryPercent % 47) == 0)) { + SetBatteryLevel(batteryPercentRemaining.Get(), orangeColor); + } + if ((chargingBatteryPercent % 97) == 0) { + SetBatteryLevel(batteryPercentRemaining.Get(), grayColor); + } + } else if (isCharging.IsUpdated() || batteryPercentRemaining.IsUpdated()) { + chargingBatteryPercent = batteryPercentRemaining.Get(); + if (chargingBatteryPercent <= 20) { + SetBatteryLevel(chargingBatteryPercent, redColor); + } else if (chargingBatteryPercent > 99) { + SetBatteryLevel(chargingBatteryPercent, orangeColor); + } else { + SetBatteryLevel(chargingBatteryPercent, grayColor); + } + } +} + +void WatchFaceLCARS::UpdateBLE() { + bleState = bleController.IsConnected(); + bleRadioEnabled = bleController.IsRadioEnabled(); + if (bleState.IsUpdated()) { + lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get())); + lv_obj_realign(bleIcon); + } +} + +void WatchFaceLCARS::UpdateStepCount() { + stepCount = motionController.NbSteps(); + if (stepCount.IsUpdated()) { + lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); + lv_obj_realign(stepValue); + lv_obj_realign(stepIcon); + } +} + +void WatchFaceLCARS::ResetSecondsDigits() { + for (int i = 0; i < 6; ++i) { + set_label_color(label_tens[i], grayColor); + } + for (int i = 0; i < 10; ++i) { + set_label_color(label_ones[i], grayColor); + } +} + +void WatchFaceLCARS::SetBatteryLevel(uint8_t batteryPercent, const lv_color_t& color) { + lv_label_set_text_fmt(labelBattery, "%lu%%", batteryPercent); + set_label_color(labelBattery, color); + lv_obj_realign(labelBattery); + lv_obj_realign(bleIcon); +} + +bool WatchFaceLCARS::IsAvailable(Pinetime::Controllers::FS& filesystem) { + lfs_file file = {}; + + if (filesystem.FileOpen(&file, "/fonts/antonio_78.bin", LFS_O_RDONLY) < 0) { + return false; + } + filesystem.FileClose(&file); + if (filesystem.FileOpen(&file, "/fonts/antonio_33.bin", LFS_O_RDONLY) < 0) { + return false; + } + filesystem.FileClose(&file); + if (filesystem.FileOpen(&file, "/fonts/antonio_21.bin", LFS_O_RDONLY) < 0) { + return false; + } + filesystem.FileClose(&file); + if (filesystem.FileOpen(&file, "/fonts/antonio_13.bin", LFS_O_RDONLY) < 0) { + return false; + } + filesystem.FileClose(&file); + return true; +} diff --git a/src/displayapp/screens/WatchFaceLCARS.h b/src/displayapp/screens/WatchFaceLCARS.h new file mode 100644 index 0000000000..5980426998 --- /dev/null +++ b/src/displayapp/screens/WatchFaceLCARS.h @@ -0,0 +1,173 @@ +#pragma once + +#include +#include +#include +#include +#include +#include "displayapp/screens/Screen.h" +#include "components/datetime/DateTimeController.h" +#include "components/ble/SimpleWeatherService.h" +#include "utility/DirtyValue.h" +#include "displayapp/apps/Apps.h" + +namespace Pinetime { + namespace Controllers { + class Settings; + class Battery; + class Ble; + class NotificationManager; + class MotionController; + } + + namespace Applications { + namespace Screens { + + class WatchFaceLCARS : public Screen { + public: + WatchFaceLCARS(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::MotionController& motionController, + Controllers::HeartRateController& heartRateController, + Controllers::SimpleWeatherService& weatherService, + Controllers::FS& fs); + + ~WatchFaceLCARS() override; + + void Refresh() override; + + static bool IsAvailable(Pinetime::Controllers::FS& filesystem); + + private: + uint32_t savedTick = 0; + uint8_t chargingBatteryPercent = 101; // not a mistake ;) + + uint8_t last_second = 60; + + bool showed_vitals_last = false; + + const char* weekNumberFormat = "%V"; + + static constexpr lv_color_t grayColor = LV_COLOR_MAKE(0x99, 0x99, 0x99); + static constexpr lv_color_t orangeColor = LV_COLOR_MAKE(0xFF, 0x99, 0x33); + static constexpr lv_color_t redColor = LV_COLOR_MAKE(0xDD, 0x44, 0x44); + + static constexpr lv_color_t bgColor = LV_COLOR_BLACK; + static constexpr lv_color_t bgBlackColor = LV_COLOR_BLACK; + static constexpr lv_color_t bgRedColor = LV_COLOR_MAKE(0xe6, 0x44, 0x4a); + static constexpr lv_color_t bgBlueColor = LV_COLOR_MAKE(0x31, 0x69, 0xd5); + static constexpr lv_color_t bgLightBlueColor = LV_COLOR_MAKE(0x8b, 0xce, 0xff); + static constexpr lv_color_t bgVioletColor = LV_COLOR_MAKE(0x9c, 0x44, 0xff); + static constexpr lv_color_t bgLightVioletColor = LV_COLOR_MAKE(0xd5, 0x99, 0xd5); + static constexpr lv_color_t bgOrangeColor = LV_COLOR_MAKE(0xff, 0x99, 0x31); + static constexpr lv_color_t bgYellowColor = LV_COLOR_MAKE(0xff, 0xce, 0x9c); + + Utility::DirtyValue batteryPercentRemaining {}; + Utility::DirtyValue isCharging {}; + Utility::DirtyValue bleState {}; + Utility::DirtyValue bleRadioEnabled {}; + Utility::DirtyValue> currentDateTime {}; + Utility::DirtyValue> currentNanoSeconds {}; + Utility::DirtyValue stepCount {}; + Utility::DirtyValue heartbeat {}; + Utility::DirtyValue heartbeatRunning {}; + Utility::DirtyValue> currentWeather {}; + Utility::DirtyValue notificationState {}; + using days = std::chrono::duration>; // TODO: days is standard in c++20 + Utility::DirtyValue> currentDate; + Utility::DirtyValue notificationCount {}; + + lv_obj_t* bg_system_shapes[10]; + lv_obj_t* bg_stardate_shapes[9]; + lv_obj_t* bg_sensors; + lv_obj_t* bg_vitals_shapes[6]; + lv_obj_t* bg_movement; + + lv_obj_t* bg_label_system; + lv_obj_t* bg_label_stardate; + lv_obj_t* bg_label_time; + lv_obj_t* bg_label_sensors; + lv_obj_t* bg_label_vitals_or_weather; + lv_obj_t* bg_label_movement; + + lv_obj_t* timeContainer; + lv_obj_t* labelTime; + lv_obj_t* labelTimeAmPm; + lv_obj_t* label_week; + lv_obj_t* label_seconds_container; + lv_obj_t* label_tens_container; + lv_obj_t* label_ones_container; + lv_obj_t* label_tens[6]; + lv_obj_t* label_ones[10]; + lv_obj_t* dateContainer; + lv_obj_t* labelDate; + lv_obj_t* labelBattery; + lv_obj_t* system_container; + lv_obj_t* sensors_container; + lv_obj_t* bleIcon; + lv_obj_t* stepIcon; + lv_obj_t* stepValue; + lv_obj_t* heartbeatOrWeatherValue; + lv_obj_t* heartbeatIcon; + lv_obj_t* weatherIcon; + lv_obj_t* notificationIcon; + + Controllers::DateTime& dateTimeController; + const Controllers::Battery& batteryController; + const Controllers::Ble& bleController; + Controllers::NotificationManager& notificationManager; + Controllers::Settings& settingsController; + Controllers::MotionController& motionController; + Controllers::HeartRateController& heartRateController; + Controllers::SimpleWeatherService& weatherService; + + void SetBatteryLevel(uint8_t batteryPercent, const lv_color_t& color); + void ResetSecondsDigits(); + void UpdateStepCount(); + void UpdateNotification(); + void UpdateBLE(); + void UpdateBatteryPercent(); + void UpdateStardate(); + void UpdateWK(); + void UpdateSeconds(); + void UpdateTime(); + bool ShowHeartRate(); + void UpdateHeartRate(); + bool ShowWeather(); + void UpdateWeather(); + + lv_task_t* taskRefresh; + lv_font_t* font_antonio_78 = nullptr; + lv_font_t* font_antonio_33 = nullptr; + lv_font_t* font_antonio_21 = nullptr; + lv_font_t* font_antonio_13 = nullptr; + lv_font_t* font_antonio_12 = nullptr; + }; + } + + template <> + struct WatchFaceTraits { + static constexpr WatchFace watchFace = WatchFace::LCARS; + static constexpr const char* name = "LCARS face"; + + static Screens::Screen* Create(AppControllers& controllers) { + return new Screens::WatchFaceLCARS(controllers.dateTimeController, + controllers.batteryController, + controllers.bleController, + controllers.notificationManager, + controllers.settingsController, + controllers.motionController, + controllers.heartRateController, + *controllers.weatherController, + controllers.filesystem); + }; + + static bool IsAvailable(Pinetime::Controllers::FS& filesystem) { + return Screens::WatchFaceLCARS::IsAvailable(filesystem); + } + }; + } +} diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h index 9edc1f7ac8..fc0bcf44c4 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.h +++ b/src/displayapp/screens/settings/SettingWatchFace.h @@ -10,6 +10,7 @@ #include "displayapp/screens/Symbols.h" #include "displayapp/screens/CheckboxList.h" #include "displayapp/screens/WatchFaceInfineat.h" +#include "displayapp/screens/WatchFaceLCARS.h" #include "displayapp/screens/WatchFaceCasioStyleG7710.h" namespace Pinetime { diff --git a/src/resources/fonts.json b/src/resources/fonts.json index c4a63349a1..26b7a24705 100644 --- a/src/resources/fonts.json +++ b/src/resources/fonts.json @@ -58,5 +58,65 @@ "size": 115, "format": "bin", "target_path": "/fonts/" + }, + "antonio_78" : { + "sources": [ + { + "file": "fonts/antonio.ttf", + "symbols": "0123456789:" + } + ], + "bpp": 1, + "size": 78, + "format": "bin", + "target_path": "/fonts/" + }, + "antonio_33" : { + "sources": [ + { + "file": "fonts/antonio.ttf", + "symbols": "0123456789WK" + } + ], + "bpp": 1, + "size": 33, + "format": "bin", + "target_path": "/fonts/" + }, + "antonio_21" : { + "sources": [ + { + "file": "fonts/antonio.ttf", + "symbols": "0123456789:APMONTUEWDHFRISATJBYLGKVZ%°- " + } + ], + "bpp": 1, + "size": 21, + "format": "bin", + "target_path": "/fonts/" + }, + "antonio_13" : { + "sources": [ + { + "file": "fonts/antonio.ttf", + "symbols": "0123456789 " + } + ], + "bpp": 1, + "size": 13, + "format": "bin", + "target_path": "/fonts/" + }, + "antonio_12" : { + "sources": [ + { + "file": "fonts/antonio.ttf", + "symbols": "MSTVWadehilmnorstvy" + } + ], + "bpp": 1, + "size": 12, + "format": "bin", + "target_path": "/fonts/" } } diff --git a/src/resources/fonts/antonio.license b/src/resources/fonts/antonio.license new file mode 100644 index 0000000000..a4b39779cc --- /dev/null +++ b/src/resources/fonts/antonio.license @@ -0,0 +1,48 @@ + +SIL Open Font License v1.10 + +This license can also be found at this permalink: https://www.fontsquirrel.com/license/antonio + +Copyright (c) 2011-12, vernon adams (vern@newtypography.co.uk), with Reserved Font Names ‘Antonio’ + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + +—————————————————————————————- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +—————————————————————————————- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. + +DEFINITIONS +“Font Software” refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. + +“Reserved Font Name” refers to any names specified as such after the copyright statement(s). + +“Original Version” refers to the collection of Font Software components as distributed by the Copyright Holder(s). + +“Modified Version” refers to any derivative made by adding to, deleting, or substituting—in part or in whole—any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. + +“Author” refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. + +5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/src/resources/fonts/antonio.ttf b/src/resources/fonts/antonio.ttf new file mode 100644 index 0000000000..27615c3384 Binary files /dev/null and b/src/resources/fonts/antonio.ttf differ diff --git a/src/resources/images/LCARS.png b/src/resources/images/LCARS.png new file mode 100644 index 0000000000..154ec2a10c Binary files /dev/null and b/src/resources/images/LCARS.png differ diff --git a/src/resources/images/LCARS.svg b/src/resources/images/LCARS.svg new file mode 100644 index 0000000000..dff22dcd6a --- /dev/null +++ b/src/resources/images/LCARS.svg @@ -0,0 +1,402 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Stardate + Time + Sensors + Vitals + Movement + System + + +