From eb8bd4dc4ecbbf61f1e0f725fd2116ee25319fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=9C=D0=B0?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= <13werwolf13@mail.ru> Date: Thu, 20 Jan 2022 23:50:04 +0500 Subject: [PATCH] add ble state text output --- src/displayapp/screens/WatchFaceTerminal.cpp | 42 +++++++++++++++----- src/displayapp/screens/WatchFaceTerminal.h | 1 + 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp index 88a1c887..eef82286 100644 --- a/src/displayapp/screens/WatchFaceTerminal.cpp +++ b/src/displayapp/screens/WatchFaceTerminal.cpp @@ -55,7 +55,7 @@ WatchFaceTerminal::WatchFaceTerminal(DisplayApp* app, lv_obj_align(batteryPercent, 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_label_set_text(bleValue, "Connected"); lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40); bleIcon = lv_label_create(lv_scr_act(), nullptr); @@ -115,17 +115,18 @@ void WatchFaceTerminal::Refresh() { lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); auto isCharging = batteryController.IsCharging() || batteryController.IsPowerPresent(); lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging)); + } - char* bleValue; + /*char* bleValue;*/ bleState = bleController.IsConnected(); if (bleState.IsUpdated()) { if (bleState.Get() == true) { lv_label_set_text(bleIcon, BleIcon::GetIcon(true)); - bleValue = "Connected"; + lv_label_set_text(bleValue, "Connected#"); } else { lv_label_set_text(bleIcon, BleIcon::GetIcon(false)); - bleValue = "Disconnected"; + lv_label_set_text(bleValue, "Disonnected#"); } } lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, -5, 5); @@ -134,10 +135,11 @@ void WatchFaceTerminal::Refresh() { notificationState = notificatioManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { - if (notificationState.Get() == true) + if (notificationState.Get() == true) { lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true)); - else + } else { lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false)); + } } currentDateTime = dateTimeController.CurrentDateTime(); @@ -163,14 +165,33 @@ void WatchFaceTerminal::Refresh() { char hoursChar[8]; - char secondsChar[5]; - sprintf(secondsChar, "%02d", static_cast(second)); + char ampmChar[3]; + if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) { + sprintf(hoursChar, "%02d", hour); + } else { + if (hour == 0 && hour != 12) { + hour = 12; + sprintf(ampmChar, "AM"); + } else if (hour == 12 && hour != 0) { + hour = 12; + sprintf(ampmChar, "PM"); + } else if (hour < 12 && hour != 0) { + sprintf(ampmChar, "AM"); + } else if (hour > 12 && hour != 0) { + hour = hour - 12; + sprintf(ampmChar, "PM"); + } + sprintf(hoursChar, "%02d", hour); + } auto batteryValue = static_cast(batteryController.PercentRemaining()); char battStr[24]; sprintf(battStr, "[BATT]#387b54 %d%\%#", batteryValue); lv_label_set_text(batteryPercent, battStr); + + char secondsChar[5]; + sprintf(secondsChar, "%02d", static_cast(second)); char bleStr[24]; sprintf(bleStr, "[STAT]#387b54 %s#", bleValue); @@ -193,13 +214,14 @@ void WatchFaceTerminal::Refresh() { char timeStr[42]; sprintf(timeStr, - "[TIME]#11cc55 %c%c:%c%c:%c%c#", + "[TIME]#11cc55 %c%c:%c%c:%c%c %s#", hoursChar[0], hoursChar[1], minutesChar[0], minutesChar[1], secondsChar[0], - secondsChar[1]); + secondsChar[1], + ampmChar); lv_label_set_text(label_time, timeStr); } diff --git a/src/displayapp/screens/WatchFaceTerminal.h b/src/displayapp/screens/WatchFaceTerminal.h index bce739c9..be10581c 100644 --- a/src/displayapp/screens/WatchFaceTerminal.h +++ b/src/displayapp/screens/WatchFaceTerminal.h @@ -68,6 +68,7 @@ namespace Pinetime { lv_obj_t* stepValue; lv_obj_t* notificationIcon; lv_obj_t* connectState; + lv_obj_t* bleValue; Controllers::DateTime& dateTimeController; Controllers::Battery& batteryController;