#include "displayapp/screens/WatchFaceDigital.h" #include #include #include #include "drivers/Hrs3300.h" #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" #include "displayapp/fonts/neofont.h" using namespace Pinetime::Applications::Screens; static inline uint8_t sprintuint4hex(uint8_t x) { return x < 10 ? '0' + x : ('A' - 10) + x; } static void sprintuint32hex(char x[9], uint32_t v) { uint16_t p = v; uint16_t q = v >> 16; uint8_t a = q >> 8; x[0] = sprintuint4hex(a>>4); x[1] = sprintuint4hex(a&0xf); a = q; x[2] = sprintuint4hex(a>>4); x[3] = sprintuint4hex(a&0xf); a = p >> 8; x[4] = sprintuint4hex(a>>4); x[5] = sprintuint4hex(a&0xf); a = p; x[6] = sprintuint4hex(a>>4); x[7] = sprintuint4hex(a&0xf); x[8] = 0; } WatchFaceDigital::WatchFaceDigital(DisplayApp* app, Controllers::DateTime& dateTimeController, Controllers::Battery& batteryController, Controllers::Ble& bleController, Controllers::NotificationManager& notificatioManager, Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, Controllers::MotionController& motionController, System::SystemTask& systemTask) : Screen(app), systemTask {systemTask}, currentDateTime {{}}, dateTimeController {dateTimeController}, batteryController {batteryController}, bleController {bleController}, notificatioManager {notificatioManager}, settingsController {settingsController}, heartRateController {heartRateController}, motionController {motionController} { lv_obj_t *area1, *area2, *area3, *area4, *area5, *area6, *area7, *area8, *area9, *area10, *area11; if (1) { lv_obj_t * b1, * l1; area3 = b1 = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000099)); lv_obj_set_style_local_radius(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(b1, 96, 48); lv_obj_align(b1, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 144, 0); l1 = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(l1, "3"); lv_obj_set_style_local_text_color(l1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_align(l1, b1, LV_ALIGN_IN_TOP_MID, 0, 0); area6 = b1 = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x444488)); lv_obj_set_style_local_text_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x3b5d6e)); lv_obj_set_size(b1, 96, 48); lv_obj_align(b1, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 144, 48); l1 = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(l1, "6"); lv_obj_set_style_local_text_color(l1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_align(l1, b1, LV_ALIGN_IN_TOP_MID, 0, 0); area1 = b1 = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x444488)); lv_obj_set_style_local_radius(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(b1, 96, 48); lv_obj_align(b1, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0); l1 = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(l1, "1"); lv_obj_set_style_local_text_color(l1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_align(l1, b1, LV_ALIGN_IN_TOP_MID, 0, 0); area4 = b1 = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x444488)); lv_obj_set_style_local_radius(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(b1, 48, 48); lv_obj_align(b1, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 48); l1 = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(l1, "4"); lv_obj_set_style_local_text_color(l1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_align(l1, b1, LV_ALIGN_IN_TOP_MID, 0, 0); area2 = b1 = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x336677)); lv_obj_set_size(b1, 48, 48); lv_obj_align(b1, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 96, 0); l1 = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(l1, "2"); lv_obj_set_style_local_text_color(l1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_align(l1, b1, LV_ALIGN_IN_TOP_MID, 0, 0); area5 = b1 = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x336677)); lv_obj_set_style_local_text_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x3b5d6e)); lv_obj_set_size(b1, 96, 48); lv_obj_align(b1, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 48, 48); l1 = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(l1, "5"); lv_obj_set_style_local_text_color(l1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_align(l1, b1, LV_ALIGN_IN_TOP_MID, 0, 0); area7 = b1 = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000099)); lv_obj_set_style_local_radius(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(b1, 240, 48); lv_obj_align(b1, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 96); l1 = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(l1, "7"); lv_obj_set_style_local_text_color(l1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_align(l1, b1, LV_ALIGN_IN_TOP_MID, 0, 0); area8 = b1 = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x444488)); lv_obj_set_style_local_text_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x3b5d6e)); lv_obj_set_size(b1, 96, 48); lv_obj_align(b1, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 144); l1 = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(l1, "8"); lv_obj_set_style_local_text_color(l1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_align(l1, b1, LV_ALIGN_IN_TOP_MID, 0, 0); area10 = b1 = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222277)); lv_obj_set_style_local_radius(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(b1, 48, 48); lv_obj_align(b1, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 192, 144); l1 = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(l1, "10"); lv_obj_set_style_local_text_color(l1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_align(l1, b1, LV_ALIGN_IN_TOP_MID, 0, 0); area11 = b1 = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222277)); lv_obj_set_style_local_radius(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(b1, 240, 48); lv_obj_align(b1, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 192); l1 = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(l1, "11"); lv_obj_set_style_local_text_color(l1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_align(l1, b1, LV_ALIGN_IN_RIGHT_MID, 0, 0); area9 = b1 = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x336677)); lv_obj_set_style_local_text_color(b1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x3b5d6e)); lv_obj_set_size(b1, 96, 48); lv_obj_align(b1, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 96, 144); l1 = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(l1, "9"); lv_obj_set_style_local_text_color(l1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_align(l1, b1, LV_ALIGN_IN_TOP_MID, 0, 0); } batteryIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_fmt(batteryIcon, "B##%%"); lv_obj_set_style_local_text_font(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); batteryPlug = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFF00)); lv_label_set_text_static(batteryPlug, ""); lv_obj_align(batteryPlug, batteryIcon, 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, lv_color_hex(0x0082FC)); 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, lv_color_hex(0x00FF00)); lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); label_temp = lv_label_create(area3, nullptr); lv_obj_set_style_local_text_color( label_temp, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCCCCCC)); lv_obj_set_style_local_text_font( label_temp, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont15); lv_label_set_text_fmt(label_temp, "??°C"); lv_obj_align(label_temp, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); label_time = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont3); lv_label_set_text_fmt(label_time, hhmm_label_text); lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_label_set_long_mode(label_time, LV_LABEL_LONG_CROP); lv_label_set_align(label_time, LV_LABEL_ALIGN_RIGHT); #if 0 label_time_sec = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(label_time_sec, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); lv_obj_set_style_local_text_font(label_time_sec, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_fmt(label_time_sec, ":??"); lv_obj_align(label_time_sec, label_time, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 0); #else label_time_sec = lv_label_create(lv_scr_act(), nullptr); // lv_obj_set_style_local_text_color(label_time_sec, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); lv_obj_set_style_local_text_font(label_time_sec, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_fmt(label_time_sec, ":??"); lv_obj_align(label_time_sec, label_time, LV_ALIGN_OUT_RIGHT_BOTTOM, 0, 0); // -2 #endif label_time_pm = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(label_time_pm, "P"); lv_obj_set_style_local_text_font(label_time_pm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont1); lv_obj_align(label_time_pm, label_time, LV_ALIGN_OUT_LEFT_TOP, 0, 0); // lv_obj_set_hidden(label_time_pm, 1); label_date_dd = lv_label_create(lv_scr_act(), nullptr); // lv_obj_set_style_local_text_color(label_date_dd, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); lv_label_set_text_fmt(label_date_dd, "DD"); lv_obj_set_style_local_text_font(label_date_dd, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_obj_align(label_date_dd, label_time, LV_ALIGN_OUT_TOP_MID, 0, 0); lv_label_set_long_mode(label_date_dd, LV_LABEL_LONG_CROP); lv_label_set_align(label_date_dd, LV_LABEL_ALIGN_CENTER); label_date_dow = lv_label_create(lv_scr_act(), nullptr); // lv_obj_set_style_local_text_color(label_date_dow, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); lv_label_set_text_fmt(label_date_dow, "DOW "); lv_obj_set_style_local_text_font(label_date_dow, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_obj_align(label_date_dow, label_date_dd, LV_ALIGN_OUT_LEFT_MID, 0, 0); label_date_mmm = lv_label_create(lv_scr_act(), nullptr); // lv_obj_set_style_local_text_color(label_date_mmm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); lv_label_set_text_fmt(label_date_mmm, "MMM"); lv_obj_set_style_local_text_font(label_date_mmm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont15); lv_obj_align(label_date_mmm, label_date_dd, LV_ALIGN_OUT_TOP_MID, 0, 0); label_date_yyyy = lv_label_create(lv_scr_act(), nullptr); // lv_obj_set_style_local_text_color(label_date_yyyy, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); lv_label_set_text_fmt(label_date_yyyy, "YYYY"); lv_obj_set_style_local_text_font(label_date_yyyy, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont0); lv_obj_align(label_date_yyyy, label_date_mmm, LV_ALIGN_OUT_TOP_MID, 0, 0); lv_label_set_long_mode(label_date_yyyy, LV_LABEL_LONG_CROP); lv_label_set_align(label_date_yyyy, LV_LABEL_ALIGN_CENTER); 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_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); lv_obj_set_style_local_text_font(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat); lv_obj_align(heartbeatIcon, area8, 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_obj_set_style_local_text_font(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(heartbeatValue, "???"); lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 0, 0); lv_label_set_align(heartbeatValue, LV_LABEL_ALIGN_RIGHT); sprintuint32hex(hrs_label_text, 0x33); hrsValue = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color( hrsValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); lv_obj_set_style_local_text_font( hrsValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont15); lv_obj_align(hrsValue, heartbeatValue, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); lv_label_set_text_static(hrsValue, hrs_label_text); sprintuint32hex(als_label_text, 0x15617811); alsValue = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color( alsValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFAA)); lv_obj_set_style_local_text_font( alsValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont15); lv_obj_align(alsValue, hrsValue, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); lv_label_set_text_static(alsValue, als_label_text); taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); lv_obj_del(area1); lv_obj_del(area2); lv_obj_del(area4); lv_obj_del(area5); lv_obj_del(area6); lv_obj_del(area7); lv_obj_del(area8); lv_obj_del(area9); lv_obj_del(area10); lv_obj_del(area11); Refresh(); } WatchFaceDigital::~WatchFaceDigital() { lv_task_del(taskRefresh); lv_obj_clean(lv_scr_act()); } void WatchFaceDigital::Refresh() { powerPresent = batteryController.IsPowerPresent(); if (powerPresent.IsUpdated()) { lv_label_set_text_static(batteryPlug, (powerPresent.Get() ? "PWR" : "")); } batteryPercentRemaining = batteryController.PercentRemaining(); if (batteryPercentRemaining.IsUpdated()) { auto batteryPercent = batteryPercentRemaining.Get(); if (batteryPercent == 100) { lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); } else { lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); } lv_label_set_text_fmt(batteryIcon, "B%d%%", batteryPercent); } bleState = bleController.IsConnected(); if (bleState.IsUpdated()) { lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get())); } lv_obj_realign(batteryIcon); lv_obj_realign(batteryPlug); lv_obj_realign(bleIcon); notificationState = notificatioManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); } #ifndef INFINISIM #if 0 lv_label_set_text_fmt(label_temp, "T%d [%d,%d]", ((int)(systemTask.motionSensor.temperature_last_read_value+23)), ((int)(systemTask.motionSensor.temperature_last_result)), ((int)(systemTask.motionSensor.temperature_read_counter))); #else temperature = systemTask.motionSensor.temperature_last_read_value+23; if (temperature.IsUpdated()) { lv_obj_set_style_local_text_color( label_temp, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); lv_label_set_text_fmt(label_temp, "%d°C", temperature.Get()); } #endif #endif currentDateTime = dateTimeController.CurrentDateTime(); if (currentDateTime.IsUpdated()) { auto newDateTime = currentDateTime.Get(); auto dp = date::floor(newDateTime); auto time = date::make_time(newDateTime - dp); auto yearMonthDay = date::year_month_day(dp); auto year = static_cast(yearMonthDay.year()); auto month = static_cast(static_cast(yearMonthDay.month())); auto day = static_cast(yearMonthDay.day()); auto dayOfWeek = static_cast(date::weekday(yearMonthDay).iso_encoding()); uint8_t hour = time.hours().count(); uint8_t minute = time.minutes().count(); uint8_t second = time.seconds().count(); if (displayedHour != hour || displayedMinute != minute) { displayedHour = hour; displayedMinute = minute; bool hide_pm = true; uint8_t h0; if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { if (hour == 0) { hour = 12; } else if (hour == 12) { hide_pm = false; } else if (hour > 12) { hour -= 12; hide_pm = false; } h0 = hour < 10 ? ' ' : '1'; } else { h0 = '0' + (hour / 10); } hhmm_label_text[0] = h0; hhmm_label_text[1] = '0' + (hour%10); hhmm_label_text[3] = '0' + (minute / 10); hhmm_label_text[4] = '0' + (minute % 10); lv_label_set_text_static(label_time, hhmm_label_text); lv_obj_set_hidden(label_time_pm, hide_pm); } if (displayedSecond != second) { displayedSecond = second; lv_label_set_text_fmt(label_time_sec, ":%02d", second); } if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) { // 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); // lv_label_set_text_static(label_date, ""); lv_label_set_text_fmt(label_date_dd, "%d", day); // should rather extract info from the timestamp lv_label_set_text_static(label_date_dow, dateTimeController.DayOfWeekShortToString()); lv_label_set_text_static(label_date_mmm, dateTimeController.MonthShortToString()); lv_label_set_text_fmt(label_date_yyyy, "%d", year); currentYear = year; currentMonth = month; currentDayOfWeek = dayOfWeek; currentDay = day; } } 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); } { auto &sensor = systemTask.heartRateSensor; sprintuint32hex(als_label_text, sensor.ReadHrs()); sprintuint32hex(hrs_label_text, sensor.ReadAls()); lv_label_set_text_static(hrsValue, hrs_label_text); lv_label_set_text_static(alsValue, als_label_text); } }