From 5866c5d6096270a0b1dfea9c8dc717236a0472c8 Mon Sep 17 00:00:00 2001 From: Michele Bini Date: Mon, 6 Jun 2022 07:18:57 +0200 Subject: Mirror batteryIcon from WatchFaceAnalog to WatchFaceAnalog24 diff --git a/src/displayapp/screens/WatchFaceAnalog24.cpp b/src/displayapp/screens/WatchFaceAnalog24.cpp index 5e37e7b..500243e 100644 --- a/src/displayapp/screens/WatchFaceAnalog24.cpp +++ b/src/displayapp/screens/WatchFaceAnalog24.cpp @@ -70,15 +70,18 @@ WatchFaceAnalog24::WatchFaceAnalog24(Pinetime::Applications::DisplayApp* app, lv_img_set_src(bg_clock_img, &bg_analog24); lv_obj_align(bg_clock_img, nullptr, LV_ALIGN_CENTER, 0, 0); - batteryIcon = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_text(batteryIcon, Symbols::batteryHalf); - lv_obj_align(batteryIcon, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0); - lv_obj_set_auto_realign(batteryIcon, true); + batteryIcon.Create(lv_scr_act()); + lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0); + + plugIcon = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_text_static(plugIcon, Symbols::plug); + lv_obj_set_style_local_text_color(plugIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); + lv_obj_align(plugIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 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, batteryIcon, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 0); + lv_obj_align(bleIcon, plugIcon, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 0); lv_obj_set_auto_realign(bleIcon, true); notificationIcon = lv_label_create(lv_scr_act(), NULL); @@ -180,21 +183,18 @@ void WatchFaceAnalog24::UpdateClock() { void WatchFaceAnalog24::SetBatteryIcon() { 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(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); + batteryIcon.SetBatteryPercentage(batteryPercent); } void WatchFaceAnalog24::Refresh() { isCharging = batteryController.IsCharging(); if (isCharging.IsUpdated()) { if (isCharging.Get()) { - lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); - lv_label_set_text(batteryIcon, Symbols::plug); + lv_obj_set_hidden(batteryIcon.GetObject(), true); + lv_obj_set_hidden(plugIcon, false); } else { + lv_obj_set_hidden(batteryIcon.GetObject(), false); + lv_obj_set_hidden(plugIcon, true); SetBatteryIcon(); } } diff --git a/src/displayapp/screens/WatchFaceAnalog24.h b/src/displayapp/screens/WatchFaceAnalog24.h index 5df8979..033519a 100644 --- a/src/displayapp/screens/WatchFaceAnalog24.h +++ b/src/displayapp/screens/WatchFaceAnalog24.h @@ -11,6 +11,7 @@ #include "components/ble/NotificationManager.h" #include "components/heartrate/HeartRateController.h" #include "components/motion/MotionController.h" +#include namespace Pinetime { namespace Controllers { @@ -65,7 +66,7 @@ namespace Pinetime { lv_style_t hour_line_style_trace; // lv_obj_t* label_date_day; - lv_obj_t* batteryIcon; + lv_obj_t* plugIcon; lv_obj_t* bleIcon; lv_obj_t* heartbeatIcon; lv_obj_t* heartbeatValue; @@ -73,6 +74,8 @@ namespace Pinetime { lv_obj_t* stepValue; lv_obj_t* notificationIcon; + BatteryIcon batteryIcon; + Controllers::DateTime& dateTimeController; Controllers::Battery& batteryController; Controllers::Ble& bleController; -- cgit v0.10.2