summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/WatchFaceAnalog.cpp
diff options
context:
space:
mode:
authorJF <JF002@users.noreply.github.com>2021-10-03 14:13:39 (GMT)
committerGitHub <noreply@github.com>2021-10-03 14:13:39 (GMT)
commitfa6c291d3ef9358af9754782ffb4fe6c0f6916dd (patch)
treec5bbcdcd592c04af08b914de5ff9142d08a356ee /src/displayapp/screens/WatchFaceAnalog.cpp
parent3442085a3c03fcc0975d1c8c46a838bc18ae5574 (diff)
parent980ac173888883b34367395fdf8ee76c0aea6f72 (diff)
Merge pull request #638 from Riksu9000/detect_full_charge
Detect full charge and improve watchface battery display
Diffstat (limited to 'src/displayapp/screens/WatchFaceAnalog.cpp')
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp
index 75e35c1..53e7faf 100644
--- a/src/displayapp/screens/WatchFaceAnalog.cpp
+++ b/src/displayapp/screens/WatchFaceAnalog.cpp
@@ -68,6 +68,7 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
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);
notificationIcon = lv_label_create(lv_scr_act(), NULL);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
@@ -176,11 +177,31 @@ void WatchFaceAnalog::UpdateClock() {
}
}
+void WatchFaceAnalog::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));
+}
+
void WatchFaceAnalog::Refresh() {
- batteryPercentRemaining = batteryController.PercentRemaining();
- if (batteryPercentRemaining.IsUpdated()) {
- auto batteryPercent = batteryPercentRemaining.Get();
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ 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);
+ } else {
+ SetBatteryIcon();
+ }
+ }
+ if (!isCharging.Get()) {
+ batteryPercentRemaining = batteryController.PercentRemaining();
+ if (batteryPercentRemaining.IsUpdated()) {
+ SetBatteryIcon();
+ }
}
notificationState = notificationManager.AreNewNotificationsAvailable();