Detect full charge and improve watchface display
This commit is contained in:
@@ -176,11 +176,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();
|
||||
|
||||
Reference in New Issue
Block a user