diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b74eb0f..134c95e4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -366,7 +366,7 @@ list(APPEND SOURCE_FILES displayapp/DisplayApp.cpp displayapp/screens/Screen.cpp displayapp/screens/Tile.cpp - displayapp/screens/InfiniPaint.cpp + #displayapp/screens/InfiniPaint.cpp displayapp/screens/Paddle.cpp displayapp/screens/StopWatch.cpp displayapp/screens/BatteryIcon.cpp @@ -420,9 +420,9 @@ list(APPEND SOURCE_FILES displayapp/screens/WatchFaceAnalog.cpp displayapp/screens/WatchFaceDigital.cpp displayapp/screens/WatchFaceInfineat.cpp - displayapp/screens/WatchFaceTerminal.cpp + #displayapp/screens/WatchFaceTerminal.cpp displayapp/screens/WatchFacePineTimeStyle.cpp - displayapp/screens/WatchFaceCasioStyleG7710.cpp + #displayapp/screens/WatchFaceCasioStyleG7710.cpp displayapp/screens/WatchFaceFuzzy.cpp ## @@ -590,7 +590,7 @@ set(INCLUDE_FILES displayapp/TouchEvents.h displayapp/screens/Screen.h displayapp/screens/Tile.h - displayapp/screens/InfiniPaint.h + #displayapp/screens/InfiniPaint.h displayapp/screens/StopWatch.h displayapp/screens/Paddle.h displayapp/screens/BatteryIcon.h diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 2792009f..03f05814 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -13,7 +13,7 @@ #include "displayapp/screens/ApplicationList.h" #include "displayapp/screens/FirmwareUpdate.h" #include "displayapp/screens/FirmwareValidation.h" -#include "displayapp/screens/InfiniPaint.h" +//#include "displayapp/screens/InfiniPaint.h" #include "displayapp/screens/Paddle.h" #include "displayapp/screens/StopWatch.h" #include "displayapp/screens/Metronome.h" diff --git a/src/displayapp/UserApps.h b/src/displayapp/UserApps.h index 01797973..f642178c 100644 --- a/src/displayapp/UserApps.h +++ b/src/displayapp/UserApps.h @@ -9,10 +9,10 @@ #include "displayapp/screens/ApplicationList.h" #include "displayapp/screens/WatchFaceDigital.h" #include "displayapp/screens/WatchFaceAnalog.h" -#include "displayapp/screens/WatchFaceCasioStyleG7710.h" +//#include "displayapp/screens/WatchFaceCasioStyleG7710.h" #include "displayapp/screens/WatchFaceInfineat.h" #include "displayapp/screens/WatchFacePineTimeStyle.h" -#include "displayapp/screens/WatchFaceTerminal.h" +//#include "displayapp/screens/WatchFaceTerminal.h" #include "displayapp/screens/WatchFaceFuzzy.h" namespace Pinetime { diff --git a/src/displayapp/apps/Apps.h.in b/src/displayapp/apps/Apps.h.in index fd70dc2c..a90efdc3 100644 --- a/src/displayapp/apps/Apps.h.in +++ b/src/displayapp/apps/Apps.h.in @@ -18,7 +18,7 @@ namespace Pinetime { FlashLight, BatteryInfo, Music, - Paint, + //Paint, Paddle, Twos, HeartRate, @@ -75,9 +75,9 @@ namespace Pinetime { using UserWatchFaceTypes = WatchFaceTypeList; static_assert(UserWatchFaceTypes::Count >= 1); diff --git a/src/displayapp/apps/CMakeLists.txt b/src/displayapp/apps/CMakeLists.txt index ddf95171..500e33f5 100644 --- a/src/displayapp/apps/CMakeLists.txt +++ b/src/displayapp/apps/CMakeLists.txt @@ -1,7 +1,9 @@ if(DEFINED ENABLE_USERAPPS) set(USERAPP_TYPES ${ENABLE_USERAPPS} CACHE STRING "List of user apps to build into the firmware") else () - set(USERAPP_TYPES "Apps::Navigation, Apps::StopWatch, Apps::Alarm, Apps::Timer, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Paint, Apps::Paddle, Apps::Twos, Apps::Metronome" CACHE STRING "List of user apps to build into the firmware") + set(USERAPP_TYPES "Apps::Navigation, Apps::StopWatch, Apps::Alarm, Apps::Timer, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Paddle, Apps::Twos" CACHE STRING "List of user apps to build into the firmware") + #Apps::Paint, + #Apps::Metronome, endif () add_library(infinitime_apps INTERFACE) diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp deleted file mode 100644 index 1d6be979..00000000 --- a/src/displayapp/screens/InfiniPaint.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "displayapp/screens/InfiniPaint.h" -#include "displayapp/DisplayApp.h" -#include "displayapp/LittleVgl.h" -#include "displayapp/InfiniTimeTheme.h" - -#include // std::fill - -using namespace Pinetime::Applications::Screens; - -InfiniPaint::InfiniPaint(Pinetime::Components::LittleVgl& lvgl, Pinetime::Controllers::MotorController& motor) - : lvgl {lvgl}, motor {motor} { - std::fill(b, b + bufferSize, selectColor); -} - -InfiniPaint::~InfiniPaint() { - lv_obj_clean(lv_scr_act()); -} - -bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) { - switch (event) { - case Pinetime::Applications::TouchEvents::LongTap: - color = (color + 1) % 8; - switch (color) { - case 0: - selectColor = LV_COLOR_MAGENTA; - break; - case 1: - selectColor = Colors::green; - break; - case 2: - selectColor = LV_COLOR_WHITE; - break; - case 3: - selectColor = LV_COLOR_RED; - break; - case 4: - selectColor = LV_COLOR_CYAN; - break; - case 5: - selectColor = LV_COLOR_YELLOW; - break; - case 6: - selectColor = LV_COLOR_BLUE; - break; - case 7: - selectColor = LV_COLOR_BLACK; - break; - - default: - color = 0; - break; - } - - std::fill(b, b + bufferSize, selectColor); - motor.RunForDuration(35); - return true; - default: - return true; - } - return true; -} - -bool InfiniPaint::OnTouchEvent(uint16_t x, uint16_t y) { - lv_area_t area; - area.x1 = x - (width / 2); - area.y1 = y - (height / 2); - area.x2 = x + (width / 2) - 1; - area.y2 = y + (height / 2) - 1; - lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::None); - lvgl.FlushDisplay(&area, b); - return true; -} diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h deleted file mode 100644 index b1f9741a..00000000 --- a/src/displayapp/screens/InfiniPaint.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include -#include -#include // std::fill -#include "displayapp/screens/Screen.h" -#include "components/motor/MotorController.h" -#include "Symbols.h" -#include "displayapp/apps/Apps.h" -#include - -namespace Pinetime { - namespace Components { - class LittleVgl; - } - - namespace Applications { - namespace Screens { - - class InfiniPaint : public Screen { - public: - InfiniPaint(Pinetime::Components::LittleVgl& lvgl, Controllers::MotorController& motor); - - ~InfiniPaint() override; - - bool OnTouchEvent(TouchEvents event) override; - - bool OnTouchEvent(uint16_t x, uint16_t y) override; - - private: - Pinetime::Components::LittleVgl& lvgl; - Controllers::MotorController& motor; - static constexpr uint16_t width = 10; - static constexpr uint16_t height = 10; - static constexpr uint16_t bufferSize = width * height; - lv_color_t b[bufferSize]; - lv_color_t selectColor = LV_COLOR_WHITE; - uint8_t color = 2; - }; - } - - template <> - struct AppTraits { - static constexpr Apps app = Apps::Paint; - static constexpr const char* icon = Screens::Symbols::paintbrush; - - static Screens::Screen* Create(AppControllers& controllers) { - return new Screens::InfiniPaint(controllers.lvgl, controllers.motorController); - }; - }; - } -} diff --git a/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp b/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp deleted file mode 100644 index 72bfaaa3..00000000 --- a/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp +++ /dev/null @@ -1,334 +0,0 @@ -#include "displayapp/screens/WatchFaceCasioStyleG7710.h" - -#include -#include -#include "displayapp/screens/BatteryIcon.h" -#include "displayapp/screens/BleIcon.h" -#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; - -WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTimeController, - const Controllers::Battery& batteryController, - const Controllers::Ble& bleController, - Controllers::NotificationManager& notificatioManager, - Controllers::Settings& settingsController, - Controllers::HeartRateController& heartRateController, - Controllers::MotionController& motionController, - Controllers::FS& filesystem) - : currentDateTime {{}}, - batteryIcon(false), - dateTimeController {dateTimeController}, - batteryController {batteryController}, - bleController {bleController}, - notificatioManager {notificatioManager}, - settingsController {settingsController}, - heartRateController {heartRateController}, - motionController {motionController} { - - lfs_file f = {}; - if (filesystem.FileOpen(&f, "/fonts/lv_font_dots_40.bin", LFS_O_RDONLY) >= 0) { - filesystem.FileClose(&f); - font_dot40 = lv_font_load("F:/fonts/lv_font_dots_40.bin"); - } - - if (filesystem.FileOpen(&f, "/fonts/7segments_40.bin", LFS_O_RDONLY) >= 0) { - filesystem.FileClose(&f); - font_segment40 = lv_font_load("F:/fonts/7segments_40.bin"); - } - - if (filesystem.FileOpen(&f, "/fonts/7segments_115.bin", LFS_O_RDONLY) >= 0) { - filesystem.FileClose(&f); - font_segment115 = lv_font_load("F:/fonts/7segments_115.bin"); - } - - label_battery_value = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(label_battery_value, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); - lv_obj_set_style_local_text_color(label_battery_value, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - lv_label_set_text_static(label_battery_value, "00%"); - - batteryIcon.Create(lv_scr_act()); - batteryIcon.SetColor(color_text); - lv_obj_align(batteryIcon.GetObject(), label_battery_value, LV_ALIGN_OUT_LEFT_MID, -5, 0); - - batteryPlug = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - lv_label_set_text_static(batteryPlug, Symbols::plug); - lv_obj_align(batteryPlug, batteryIcon.GetObject(), LV_ALIGN_OUT_LEFT_MID, -5, 0); - - bleIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - lv_label_set_text_static(bleIcon, Symbols::bluetooth); - lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0); - - notificationIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); - lv_obj_align(notificationIcon, bleIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); - - label_day_of_week = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(label_day_of_week, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 10, 64); - lv_obj_set_style_local_text_color(label_day_of_week, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - lv_obj_set_style_local_text_font(label_day_of_week, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_dot40); - lv_label_set_text_static(label_day_of_week, "SUN"); - - label_week_number = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(label_week_number, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 22); - lv_obj_set_style_local_text_color(label_week_number, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - lv_obj_set_style_local_text_font(label_week_number, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_dot40); - lv_label_set_text_static(label_week_number, "WK26"); - - label_day_of_year = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(label_day_of_year, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 100, 30); - lv_obj_set_style_local_text_color(label_day_of_year, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - lv_obj_set_style_local_text_font(label_day_of_year, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_segment40); - lv_label_set_text_static(label_day_of_year, "181-184"); - - lv_style_init(&style_line); - lv_style_set_line_width(&style_line, LV_STATE_DEFAULT, 2); - lv_style_set_line_color(&style_line, LV_STATE_DEFAULT, color_text); - lv_style_set_line_rounded(&style_line, LV_STATE_DEFAULT, true); - - lv_style_init(&style_border); - lv_style_set_line_width(&style_border, LV_STATE_DEFAULT, 6); - lv_style_set_line_color(&style_border, LV_STATE_DEFAULT, color_text); - lv_style_set_line_rounded(&style_border, LV_STATE_DEFAULT, true); - - line_icons = lv_line_create(lv_scr_act(), nullptr); - lv_line_set_points(line_icons, line_icons_points, 3); - lv_obj_add_style(line_icons, LV_LINE_PART_MAIN, &style_line); - lv_obj_align(line_icons, nullptr, LV_ALIGN_IN_TOP_RIGHT, -10, 18); - - line_day_of_week_number = lv_line_create(lv_scr_act(), nullptr); - lv_line_set_points(line_day_of_week_number, line_day_of_week_number_points, 4); - lv_obj_add_style(line_day_of_week_number, LV_LINE_PART_MAIN, &style_border); - lv_obj_align(line_day_of_week_number, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 8); - - line_day_of_year = lv_line_create(lv_scr_act(), nullptr); - lv_line_set_points(line_day_of_year, line_day_of_year_points, 3); - lv_obj_add_style(line_day_of_year, LV_LINE_PART_MAIN, &style_line); - lv_obj_align(line_day_of_year, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 60); - - label_date = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 100, 70); - lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - lv_obj_set_style_local_text_font(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_segment40); - lv_label_set_text_static(label_date, "6-30"); - - line_date = lv_line_create(lv_scr_act(), nullptr); - lv_line_set_points(line_date, line_date_points, 3); - lv_obj_add_style(line_date, LV_LINE_PART_MAIN, &style_line); - lv_obj_align(line_date, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 100); - - label_time = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_segment115); - lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 40); - - line_time = lv_line_create(lv_scr_act(), nullptr); - lv_line_set_points(line_time, line_time_points, 3); - lv_obj_add_style(line_time, LV_LINE_PART_MAIN, &style_line); - lv_obj_align(line_time, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -25); - - label_time_ampm = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(label_time_ampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - lv_label_set_text_static(label_time_ampm, ""); - lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 5, -5); - - backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_click(backgroundLabel, true); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); - lv_obj_set_size(backgroundLabel, 240, 240); - lv_obj_set_pos(backgroundLabel, 0, 0); - lv_label_set_text_static(backgroundLabel, ""); - - 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, color_text); - lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2); - - heartbeatValue = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - 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, color_text); - lv_label_set_text_static(stepValue, "0"); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2); - - stepIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); - 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(); -} - -WatchFaceCasioStyleG7710::~WatchFaceCasioStyleG7710() { - lv_task_del(taskRefresh); - - lv_style_reset(&style_line); - lv_style_reset(&style_border); - - if (font_dot40 != nullptr) { - lv_font_free(font_dot40); - } - - if (font_segment40 != nullptr) { - lv_font_free(font_segment40); - } - - if (font_segment115 != nullptr) { - lv_font_free(font_segment115); - } - - lv_obj_clean(lv_scr_act()); -} - -void WatchFaceCasioStyleG7710::Refresh() { - powerPresent = batteryController.IsPowerPresent(); - if (powerPresent.IsUpdated()) { - lv_label_set_text_static(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get())); - } - - batteryPercentRemaining = batteryController.PercentRemaining(); - if (batteryPercentRemaining.IsUpdated()) { - auto batteryPercent = batteryPercentRemaining.Get(); - batteryIcon.SetBatteryPercentage(batteryPercent); - lv_label_set_text_fmt(label_battery_value, "%d%%", batteryPercent); - } - - bleState = bleController.IsConnected(); - bleRadioEnabled = bleController.IsRadioEnabled(); - if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) { - lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get())); - } - lv_obj_realign(label_battery_value); - lv_obj_realign(batteryIcon.GetObject()); - lv_obj_realign(batteryPlug); - lv_obj_realign(bleIcon); - lv_obj_realign(notificationIcon); - - notificationState = notificatioManager.AreNewNotificationsAvailable(); - if (notificationState.IsUpdated()) { - lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); - } - - currentDateTime = std::chrono::time_point_cast(dateTimeController.CurrentDateTime()); - if (currentDateTime.IsUpdated()) { - uint8_t hour = dateTimeController.Hours(); - uint8_t minute = dateTimeController.Minutes(); - - if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { - char ampmChar[2] = "A"; - 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); - } else { - lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute); - } - lv_obj_realign(label_time); - - currentDate = std::chrono::time_point_cast(currentDateTime.Get()); - if (currentDate.IsUpdated()) { - const char* weekNumberFormat = "%V"; - - uint16_t year = dateTimeController.Year(); - Controllers::DateTime::Months month = dateTimeController.Month(); - uint8_t day = dateTimeController.Day(); - int dayOfYear = dateTimeController.DayOfYear(); - if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) { - // 24h mode: ddmmyyyy, first DOW=Monday; - lv_label_set_text_fmt(label_date, "%3d-%2d", day, month); - weekNumberFormat = "%V"; // Replaced by the week number of the year (Monday as the first day of the week) as a decimal number - // [01,53]. If the week containing 1 January has four or more days in the new year, then it is considered - // week 1. Otherwise, it is the last week of the previous year, and the next week is week 1. Both January - // 4th and the first Thursday of January are always in week 1. [ tm_year, tm_wday, tm_yday] - } else { - // 12h mode: mmddyyyy, first DOW=Sunday; - lv_label_set_text_fmt(label_date, "%3d-%2d", month, day); - weekNumberFormat = "%U"; // Replaced by the week number of the year as a decimal number [00,53]. The first Sunday of January is the - // first day of week 1; days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday] - } - - time_t ttTime = - std::chrono::system_clock::to_time_t(std::chrono::time_point_cast(currentDateTime.Get())); - tm* tmTime = std::localtime(&ttTime); - - // TODO: When we start using C++20, use std::chrono::year::is_leap - int daysInCurrentYear = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0 ? 366 : 365; - uint16_t daysTillEndOfYearNumber = daysInCurrentYear - dayOfYear; - - char buffer[8]; - strftime(buffer, 8, weekNumberFormat, tmTime); - uint8_t weekNumber = atoi(buffer); - - lv_label_set_text_fmt(label_day_of_week, "%s", dateTimeController.DayOfWeekShortToString()); - lv_label_set_text_fmt(label_day_of_year, "%3d-%3d", dayOfYear, daysTillEndOfYearNumber); - lv_label_set_text_fmt(label_week_number, "WK%02d", weekNumber); - - lv_obj_realign(label_day_of_week); - lv_obj_realign(label_day_of_year); - lv_obj_realign(label_week_number); - 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, color_text); - 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 WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) { - lfs_file file = {}; - - if (filesystem.FileOpen(&file, "/fonts/lv_font_dots_40.bin", LFS_O_RDONLY) < 0) { - return false; - } - - filesystem.FileClose(&file); - if (filesystem.FileOpen(&file, "/fonts/7segments_40.bin", LFS_O_RDONLY) < 0) { - return false; - } - - filesystem.FileClose(&file); - if (filesystem.FileOpen(&file, "/fonts/7segments_115.bin", LFS_O_RDONLY) < 0) { - return false; - } - - filesystem.FileClose(&file); - return true; -} diff --git a/src/displayapp/screens/WatchFaceCasioStyleG7710.h b/src/displayapp/screens/WatchFaceCasioStyleG7710.h deleted file mode 100644 index f10e931c..00000000 --- a/src/displayapp/screens/WatchFaceCasioStyleG7710.h +++ /dev/null @@ -1,127 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include "displayapp/screens/Screen.h" -#include "components/datetime/DateTimeController.h" -#include "components/ble/BleController.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 WatchFaceCasioStyleG7710 : public Screen { - public: - WatchFaceCasioStyleG7710(Controllers::DateTime& dateTimeController, - const Controllers::Battery& batteryController, - const Controllers::Ble& bleController, - Controllers::NotificationManager& notificatioManager, - Controllers::Settings& settingsController, - Controllers::HeartRateController& heartRateController, - Controllers::MotionController& motionController, - Controllers::FS& filesystem); - ~WatchFaceCasioStyleG7710() override; - - void Refresh() override; - - static bool IsAvailable(Pinetime::Controllers::FS& filesystem); - - private: - Utility::DirtyValue batteryPercentRemaining {}; - Utility::DirtyValue powerPresent {}; - Utility::DirtyValue bleState {}; - Utility::DirtyValue bleRadioEnabled {}; - Utility::DirtyValue> currentDateTime {}; - Utility::DirtyValue stepCount {}; - Utility::DirtyValue heartbeat {}; - Utility::DirtyValue heartbeatRunning {}; - Utility::DirtyValue notificationState {}; - using days = std::chrono::duration>; // TODO: days is standard in c++20 - Utility::DirtyValue> currentDate; - - lv_point_t line_icons_points[3] {{0, 5}, {117, 5}, {122, 0}}; - lv_point_t line_day_of_week_number_points[4] {{0, 0}, {100, 0}, {95, 95}, {0, 95}}; - lv_point_t line_day_of_year_points[3] {{0, 5}, {130, 5}, {135, 0}}; - lv_point_t line_date_points[3] {{0, 5}, {135, 5}, {140, 0}}; - lv_point_t line_time_points[3] {{0, 0}, {230, 0}, {235, 5}}; - - lv_color_t color_text = lv_color_hex(0x98B69A); - - lv_style_t style_line; - lv_style_t style_border; - - lv_obj_t* label_time; - lv_obj_t* line_time; - lv_obj_t* label_time_ampm; - lv_obj_t* label_date; - lv_obj_t* line_date; - lv_obj_t* label_day_of_week; - lv_obj_t* label_week_number; - lv_obj_t* line_day_of_week_number; - lv_obj_t* label_day_of_year; - lv_obj_t* line_day_of_year; - lv_obj_t* backgroundLabel; - lv_obj_t* bleIcon; - lv_obj_t* batteryPlug; - lv_obj_t* label_battery_value; - lv_obj_t* heartbeatIcon; - lv_obj_t* heartbeatValue; - lv_obj_t* stepIcon; - lv_obj_t* stepValue; - lv_obj_t* notificationIcon; - lv_obj_t* line_icons; - - BatteryIcon batteryIcon; - - Controllers::DateTime& dateTimeController; - const Controllers::Battery& batteryController; - const Controllers::Ble& bleController; - Controllers::NotificationManager& notificatioManager; - Controllers::Settings& settingsController; - Controllers::HeartRateController& heartRateController; - Controllers::MotionController& motionController; - - lv_task_t* taskRefresh; - lv_font_t* font_dot40 = nullptr; - lv_font_t* font_segment40 = nullptr; - lv_font_t* font_segment115 = nullptr; - }; - } - - template <> - struct WatchFaceTraits { - static constexpr WatchFace watchFace = WatchFace::CasioStyleG7710; - static constexpr const char* name = "Casio G7710"; - - static Screens::Screen* Create(AppControllers& controllers) { - return new Screens::WatchFaceCasioStyleG7710(controllers.dateTimeController, - controllers.batteryController, - controllers.bleController, - controllers.notificationManager, - controllers.settingsController, - controllers.heartRateController, - controllers.motionController, - controllers.filesystem); - }; - - static bool IsAvailable(Pinetime::Controllers::FS& filesystem) { - return Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem); - } - }; - } -} diff --git a/src/displayapp/screens/WatchFaceFuzzy.cpp b/src/displayapp/screens/WatchFaceFuzzy.cpp index 51e665bb..8f379ccc 100644 --- a/src/displayapp/screens/WatchFaceFuzzy.cpp +++ b/src/displayapp/screens/WatchFaceFuzzy.cpp @@ -47,7 +47,7 @@ WatchFaceFuzzy::WatchFaceFuzzy(Controllers::DateTime& dateTimeController, 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)); @@ -67,7 +67,7 @@ WatchFaceFuzzy::WatchFaceFuzzy(Controllers::DateTime& dateTimeController, 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(); } @@ -132,7 +132,7 @@ void WatchFaceFuzzy::Refresh() { lv_obj_realign(label_date); } } - + /* heartbeat = heartRateController.HeartRate(); heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { @@ -153,7 +153,7 @@ void WatchFaceFuzzy::Refresh() { lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); lv_obj_realign(stepValue); lv_obj_realign(stepIcon); - } + }*/ } /* Inspired by XFCE4-panel's fuzzy clock. diff --git a/src/displayapp/screens/WatchFaceFuzzy.h b/src/displayapp/screens/WatchFaceFuzzy.h index 4458fe15..e89a1911 100644 --- a/src/displayapp/screens/WatchFaceFuzzy.h +++ b/src/displayapp/screens/WatchFaceFuzzy.h @@ -44,14 +44,14 @@ namespace Pinetime { static const char* timeSectors[12]; static const char* hourNames[12]; - Utility::DirtyValue batteryPercentRemaining {}; - Utility::DirtyValue powerPresent {}; - Utility::DirtyValue bleState {}; - Utility::DirtyValue bleRadioEnabled {}; + // Utility::DirtyValue batteryPercentRemaining {}; + // Utility::DirtyValue powerPresent {}; + // Utility::DirtyValue bleState {}; + // Utility::DirtyValue bleRadioEnabled {}; Utility::DirtyValue> currentDateTime {}; - Utility::DirtyValue stepCount {}; - Utility::DirtyValue heartbeat {}; - Utility::DirtyValue heartbeatRunning {}; + // Utility::DirtyValue stepCount {}; + // Utility::DirtyValue heartbeat {}; + // Utility::DirtyValue heartbeatRunning {}; Utility::DirtyValue notificationState {}; using days = std::chrono::duration>; // TODO: days is standard in c++20 Utility::DirtyValue> currentDate; @@ -59,10 +59,10 @@ namespace Pinetime { 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* heartbeatIcon; + // lv_obj_t* heartbeatValue; + // lv_obj_t* stepIcon; + // lv_obj_t* stepValue; lv_obj_t* notificationIcon; Controllers::DateTime& dateTimeController; diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp deleted file mode 100644 index 72383729..00000000 --- a/src/displayapp/screens/WatchFaceTerminal.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include -#include "displayapp/screens/WatchFaceTerminal.h" -#include "displayapp/screens/BatteryIcon.h" -#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; - -WatchFaceTerminal::WatchFaceTerminal(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}, - batteryController {batteryController}, - bleController {bleController}, - notificationManager {notificationManager}, - settingsController {settingsController}, - heartRateController {heartRateController}, - motionController {motionController} { - batteryValue = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(batteryValue, true); - lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20); - - connectState = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(connectState, true); - lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40); - - notificationIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100); - - label_date = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(label_date, true); - lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40); - - 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"); - - 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:~ $"); - - label_time = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(label_time, true); - lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60); - - heartbeatValue = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(heartbeatValue, true); - lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20); - - stepValue = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(stepValue, true); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0); - - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); - Refresh(); -} - -WatchFaceTerminal::~WatchFaceTerminal() { - lv_task_del(taskRefresh); - lv_obj_clean(lv_scr_act()); -} - -void WatchFaceTerminal::Refresh() { - powerPresent = batteryController.IsPowerPresent(); - batteryPercentRemaining = batteryController.PercentRemaining(); - if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) { - lv_label_set_text_fmt(batteryValue, "[BATT]#387b54 %d%%", batteryPercentRemaining.Get()); - if (batteryController.IsPowerPresent()) { - lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging"); - } - } - - bleState = bleController.IsConnected(); - bleRadioEnabled = bleController.IsRadioEnabled(); - if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) { - if (!bleRadioEnabled.Get()) { - lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#"); - } else { - if (bleState.Get()) { - lv_label_set_text_static(connectState, "[STAT]#0082fc Connected#"); - } else { - lv_label_set_text_static(connectState, "[STAT]#0082fc Disconnected#"); - } - } - } - - notificationState = notificationManager.AreNewNotificationsAvailable(); - if (notificationState.IsUpdated()) { - if (notificationState.Get()) { - lv_label_set_text_static(notificationIcon, "You have mail."); - } else { - lv_label_set_text_static(notificationIcon, ""); - } - } - - currentDateTime = std::chrono::time_point_cast(dateTimeController.CurrentDateTime()); - if (currentDateTime.IsUpdated()) { - uint8_t hour = dateTimeController.Hours(); - uint8_t minute = dateTimeController.Minutes(); - uint8_t second = dateTimeController.Seconds(); - - 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_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar); - } else { - lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second); - } - - currentDate = std::chrono::time_point_cast(currentDateTime.Get()); - if (currentDate.IsUpdated()) { - uint16_t year = dateTimeController.Year(); - Controllers::DateTime::Months month = dateTimeController.Month(); - uint8_t day = dateTimeController.Day(); - lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d-%02d-%02d#", short(year), char(month), char(day)); - } - } - - heartbeat = heartRateController.HeartRate(); - heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; - if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { - if (heartbeatRunning.Get()) { - lv_label_set_text_fmt(heartbeatValue, "[L_HR]#ee3311 %d bpm#", heartbeat.Get()); - } else { - lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#"); - } - } - - stepCount = motionController.NbSteps(); - if (stepCount.IsUpdated()) { - lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get()); - } -} diff --git a/src/displayapp/screens/WatchFaceTerminal.h b/src/displayapp/screens/WatchFaceTerminal.h deleted file mode 100644 index ce22005f..00000000 --- a/src/displayapp/screens/WatchFaceTerminal.h +++ /dev/null @@ -1,93 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include "displayapp/screens/Screen.h" -#include "components/datetime/DateTimeController.h" -#include "utility/DirtyValue.h" - -namespace Pinetime { - namespace Controllers { - class Settings; - class Battery; - class Ble; - class NotificationManager; - class HeartRateController; - class MotionController; - } - - namespace Applications { - namespace Screens { - - class WatchFaceTerminal : public Screen { - public: - WatchFaceTerminal(Controllers::DateTime& dateTimeController, - const Controllers::Battery& batteryController, - const Controllers::Ble& bleController, - Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController, - Controllers::HeartRateController& heartRateController, - Controllers::MotionController& motionController); - ~WatchFaceTerminal() override; - - void Refresh() override; - - private: - Utility::DirtyValue batteryPercentRemaining {}; - Utility::DirtyValue powerPresent {}; - Utility::DirtyValue bleState {}; - Utility::DirtyValue bleRadioEnabled {}; - Utility::DirtyValue> currentDateTime {}; - Utility::DirtyValue stepCount {}; - Utility::DirtyValue heartbeat {}; - Utility::DirtyValue heartbeatRunning {}; - Utility::DirtyValue notificationState {}; - using days = std::chrono::duration>; // TODO: days is standard in c++20 - Utility::DirtyValue> currentDate; - - lv_obj_t* label_time; - lv_obj_t* label_date; - lv_obj_t* label_prompt_1; - lv_obj_t* label_prompt_2; - lv_obj_t* batteryValue; - lv_obj_t* heartbeatValue; - lv_obj_t* stepValue; - lv_obj_t* notificationIcon; - lv_obj_t* connectState; - - Controllers::DateTime& dateTimeController; - const Controllers::Battery& batteryController; - const Controllers::Ble& bleController; - Controllers::NotificationManager& notificationManager; - Controllers::Settings& settingsController; - Controllers::HeartRateController& heartRateController; - Controllers::MotionController& motionController; - - lv_task_t* taskRefresh; - }; - } - - template <> - struct WatchFaceTraits { - static constexpr WatchFace watchFace = WatchFace::Terminal; - static constexpr const char* name = "Terminal"; - - static Screens::Screen* Create(AppControllers& controllers) { - return new Screens::WatchFaceTerminal(controllers.dateTimeController, - controllers.batteryController, - controllers.bleController, - controllers.notificationManager, - controllers.settingsController, - controllers.heartRateController, - controllers.motionController); - }; - - static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) { - return true; - } - }; - } -} diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h index 66559c73..b76d72b6 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.h +++ b/src/displayapp/screens/settings/SettingWatchFace.h @@ -10,7 +10,7 @@ #include "displayapp/screens/Symbols.h" #include "displayapp/screens/CheckboxList.h" #include "displayapp/screens/WatchFaceInfineat.h" -#include "displayapp/screens/WatchFaceCasioStyleG7710.h" +//#include "displayapp/screens/WatchFaceCasioStyleG7710.h" namespace Pinetime {