summaryrefslogtreecommitdiff
path: root/src/displayapp/screens
diff options
context:
space:
mode:
authorDiego Miguel <dmlls@diegomiguel.me>2022-04-03 17:20:25 +0200
committerDiego Miguel <dmlls@diegomiguel.me>2022-06-11 16:57:24 +0200
commitcb2131ec2cc26a55131192e86287dd6f5fe3e472 (patch)
treecef267faa28a6dd048427a057f1fdba231891498 /src/displayapp/screens
parentb5bf6c51a462a94d2765cc33dd6a8afa0836e8ef (diff)
Implement charging battery animation
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/WatchFaceInfineat.cpp19
-rw-r--r--src/displayapp/screens/WatchFaceInfineat.h4
2 files changed, 18 insertions, 5 deletions
diff --git a/src/displayapp/screens/WatchFaceInfineat.cpp b/src/displayapp/screens/WatchFaceInfineat.cpp
index b9b13a09..c5c18d0d 100644
--- a/src/displayapp/screens/WatchFaceInfineat.cpp
+++ b/src/displayapp/screens/WatchFaceInfineat.cpp
@@ -145,7 +145,7 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app,
lv_style_set_line_width(&lineBatteryStyle, LV_STATE_DEFAULT, 24);
lv_style_set_line_color(&lineBatteryStyle, LV_STATE_DEFAULT,
lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 4]));
- lv_style_set_line_opa(&lineBatteryStyle, LV_STATE_DEFAULT, LV_OPA_80);
+ lv_style_set_line_opa(&lineBatteryStyle, LV_STATE_DEFAULT, 190);
lv_obj_add_style(lineBattery, LV_LINE_PART_MAIN, &lineBatteryStyle);
lineBatteryPoints[0] = {27, 105};
lineBatteryPoints[1] = {27, 106};
@@ -484,9 +484,20 @@ void WatchFaceInfineat::Refresh() {
}
batteryPercentRemaining = batteryController.PercentRemaining();
- if (batteryPercentRemaining.IsUpdated()) {
- auto batteryPercent = batteryPercentRemaining.Get();
- SetBatteryLevel(batteryPercent);
+ isCharging = batteryController.IsCharging();
+ // We store if battery and charging are updated before calling Get(),
+ // since Get() sets isUpdated to false.
+ bool isBatteryUpdated = batteryPercentRemaining.IsUpdated();
+ bool isChargingUpdated = isCharging.IsUpdated();
+ if (isCharging.Get()) { // Charging battery animation
+ chargingBatteryPercent += 1;
+ if (chargingBatteryPercent > 100) {
+ chargingBatteryPercent = batteryPercentRemaining.Get();
+ }
+ SetBatteryLevel(chargingBatteryPercent);
+ } else if (isChargingUpdated || isBatteryUpdated) {
+ chargingBatteryPercent = batteryPercentRemaining.Get();
+ SetBatteryLevel(chargingBatteryPercent);
}
bleState = bleController.IsConnected();
diff --git a/src/displayapp/screens/WatchFaceInfineat.h b/src/displayapp/screens/WatchFaceInfineat.h
index 42d2d16d..54e3cb74 100644
--- a/src/displayapp/screens/WatchFaceInfineat.h
+++ b/src/displayapp/screens/WatchFaceInfineat.h
@@ -46,9 +46,11 @@ namespace Pinetime {
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0;
uint32_t savedTick = 0;
+ uint8_t chargingBatteryPercent = 101; // not a mistake ;)
+
DirtyValue<uint8_t> batteryPercentRemaining {};
- DirtyValue<bool> powerPresent {};
+ DirtyValue<bool> isCharging {};
DirtyValue<bool> bleState {};
DirtyValue<bool> bleRadioEnabled {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};