Detect full charge and improve watchface display

This commit is contained in:
Riku Isokoski
2021-09-03 14:35:38 +03:00
parent 6f9f0e8b0e
commit fd52ca8fe6
9 changed files with 75 additions and 26 deletions

View File

@@ -102,12 +102,20 @@ WatchFaceDigital::~WatchFaceDigital() {
}
void WatchFaceDigital::Refresh() {
isCharging = batteryController.IsCharging();
if (isCharging.IsUpdated()) {
lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging.Get()));
}
batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated()) {
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));
auto isCharging = batteryController.IsCharging() or batteryController.IsPowerPresent();
lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging));
}
bleState = bleController.IsConnected();