diff options
| author | JF <JF002@users.noreply.github.com> | 2021-10-03 14:13:39 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-03 14:13:39 (GMT) |
| commit | fa6c291d3ef9358af9754782ffb4fe6c0f6916dd (patch) | |
| tree | c5bbcdcd592c04af08b914de5ff9142d08a356ee /src/displayapp/screens/PineTimeStyle.cpp | |
| parent | 3442085a3c03fcc0975d1c8c46a838bc18ae5574 (diff) | |
| parent | 980ac173888883b34367395fdf8ee76c0aea6f72 (diff) | |
Merge pull request #638 from Riksu9000/detect_full_charge
Detect full charge and improve watchface battery display
Diffstat (limited to 'src/displayapp/screens/PineTimeStyle.cpp')
| -rw-r--r-- | src/displayapp/screens/PineTimeStyle.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 7a712f4..6766ecb 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -100,10 +100,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_label_set_text(batteryIcon, Symbols::batteryFull); lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2); - - 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(0x000000)); - lv_obj_align(batteryPlug, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2); + lv_obj_set_auto_realign(batteryIcon, true); 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(0x000000)); @@ -205,18 +202,24 @@ PineTimeStyle::~PineTimeStyle() { lv_obj_clean(lv_scr_act()); } +void PineTimeStyle::SetBatteryIcon() { + auto batteryPercent = batteryPercentRemaining.Get(); + lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); +} + void PineTimeStyle::Refresh() { - batteryPercentRemaining = batteryController.PercentRemaining(); - if (batteryPercentRemaining.IsUpdated()) { - auto batteryPercent = batteryPercentRemaining.Get(); - if (batteryController.IsCharging()) { - auto isCharging = batteryController.IsCharging() || batteryController.IsPowerPresent(); - lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging)); - lv_obj_realign(batteryPlug); - lv_label_set_text(batteryIcon, ""); + isCharging = batteryController.IsCharging(); + if (isCharging.IsUpdated()) { + if (isCharging.Get()) { + lv_label_set_text(batteryIcon, Symbols::plug); } else { - lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); - lv_label_set_text(batteryPlug, ""); + SetBatteryIcon(); + } + } + if (!isCharging.Get()) { + batteryPercentRemaining = batteryController.PercentRemaining(); + if (batteryPercentRemaining.IsUpdated()) { + SetBatteryIcon(); } } |
