From 49b92cdd1efd478629ef0542300c7318db27deab Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 9 May 2024 09:17:47 -0400 Subject: [PATCH] Work on adding battery percent to status icons --- src/displayapp/widgets/StatusIcons.cpp | 5 +++++ src/displayapp/widgets/StatusIcons.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/displayapp/widgets/StatusIcons.cpp b/src/displayapp/widgets/StatusIcons.cpp index 423b53d9..bf330140 100644 --- a/src/displayapp/widgets/StatusIcons.cpp +++ b/src/displayapp/widgets/StatusIcons.cpp @@ -14,6 +14,10 @@ void StatusIcons::Create() { lv_obj_set_style_local_pad_inner(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); lv_obj_set_style_local_bg_opa(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); + 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_label_set_text_static(label_battery_value, "00%"); + bleIcon = lv_label_create(container, nullptr); lv_label_set_text_static(bleIcon, Screens::Symbols::bluetooth); @@ -35,6 +39,7 @@ void StatusIcons::Update() { if (batteryPercentRemaining.IsUpdated()) { auto batteryPercent = batteryPercentRemaining.Get(); batteryIcon.SetBatteryPercentage(batteryPercent); + lv_label_set_text_fmt(label_battery_value, "%d%%", batteryPercent); } bleState = bleController.IsConnected(); diff --git a/src/displayapp/widgets/StatusIcons.h b/src/displayapp/widgets/StatusIcons.h index 9e21d3ad..8d8cf7c6 100644 --- a/src/displayapp/widgets/StatusIcons.h +++ b/src/displayapp/widgets/StatusIcons.h @@ -36,6 +36,7 @@ namespace Pinetime { lv_obj_t* bleIcon; lv_obj_t* batteryPlug; lv_obj_t* container; + lv_obj_t* label_battery_value; }; } }