diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-06-06 05:18:57 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-06-06 23:10:00 (GMT) |
| commit | 4290b321a71ce85f8365ed6206d6e89d8a2404b5 (patch) | |
| tree | e43ebd189b0b5dc0eb5d69a366545d4d64d94a43 | |
| parent | 7c45f185a32c7bcff47c8fda1acdec82d3213717 (diff) | |
Mirror batteryIcon from WatchFaceAnalog to WatchFaceAnalog24
| -rw-r--r-- | src/displayapp/screens/WatchFaceAnalog24.cpp | 26 | ||||
| -rw-r--r-- | src/displayapp/screens/WatchFaceAnalog24.h | 5 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/displayapp/screens/WatchFaceAnalog24.cpp b/src/displayapp/screens/WatchFaceAnalog24.cpp index 00df484..ba123f4 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 <displayapp/screens/BatteryIcon.h> 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; |
