From 20b31fdbe5667930ad9ec1fae5dd13010c783a47 Mon Sep 17 00:00:00 2001 From: Diego Miguel Date: Sat, 21 May 2022 14:04:49 +0200 Subject: [PATCH] Show battery indicator when side cover hidden --- src/displayapp/screens/WatchFaceInfineat.cpp | 19 +++++++++++++++---- src/displayapp/screens/WatchFaceInfineat.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/displayapp/screens/WatchFaceInfineat.cpp b/src/displayapp/screens/WatchFaceInfineat.cpp index 215a7db6..d4b7c446 100644 --- a/src/displayapp/screens/WatchFaceInfineat.cpp +++ b/src/displayapp/screens/WatchFaceInfineat.cpp @@ -153,7 +153,7 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_obj_move_foreground(lineBattery); if(!settingsController.GetInfineatShowSideCover()) { - lv_obj_set_hidden(logoPine, true); + ToggleBatteryIndicatorColor(false); lv_obj_set_hidden(line0, true); lv_obj_set_hidden(line1, true); lv_obj_set_hidden(line2, true); @@ -163,7 +163,6 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_obj_set_hidden(line6, true); lv_obj_set_hidden(line7, true); lv_obj_set_hidden(line8, true); - lv_obj_set_hidden(lineBattery, true); } notificationIcon = lv_obj_create(lv_scr_act(), nullptr); @@ -338,7 +337,7 @@ void WatchFaceInfineat::UpdateSelected(lv_obj_t* object, lv_event_t event) { } if (object == btnToggleCover) { settingsController.SetInfineatShowSideCover(!showSideCover); - lv_obj_set_hidden(logoPine, showSideCover); + ToggleBatteryIndicatorColor(!showSideCover); lv_obj_set_hidden(line0, showSideCover); lv_obj_set_hidden(line1, showSideCover); lv_obj_set_hidden(line2, showSideCover); @@ -348,7 +347,6 @@ void WatchFaceInfineat::UpdateSelected(lv_obj_t* object, lv_event_t event) { lv_obj_set_hidden(line6, showSideCover); lv_obj_set_hidden(line7, showSideCover); lv_obj_set_hidden(line8, showSideCover); - lv_obj_set_hidden(lineBattery, showSideCover); lv_obj_set_hidden(btnNextColor, showSideCover); lv_obj_set_hidden(btnPrevColor, showSideCover); const char* labelToggle = showSideCover ? "OFF" : "ON"; @@ -520,3 +518,16 @@ void WatchFaceInfineat::SetBatteryLevel(uint8_t batteryPercent) { lineBatteryPoints[1] = {27, static_cast(105 + 32*(100-batteryPercent)/100)}; lv_line_set_points(lineBattery, lineBatteryPoints, 2); } + +void WatchFaceInfineat::ToggleBatteryIndicatorColor(bool showSideCover) { + if (!showSideCover) { // make indicator white + lv_obj_set_style_local_image_recolor_opa(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_100); + lv_obj_set_style_local_image_recolor(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_style_set_line_color(&lineBatteryStyle, LV_STATE_DEFAULT, LV_COLOR_BLACK); + } else { + lv_obj_set_style_local_image_recolor_opa(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0); + lv_style_set_line_color(&lineBatteryStyle, LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 4])); + } + lv_obj_add_style(lineBattery, LV_LINE_PART_MAIN, &lineBatteryStyle); +} diff --git a/src/displayapp/screens/WatchFaceInfineat.h b/src/displayapp/screens/WatchFaceInfineat.h index 3e4491fe..b6f5f08c 100644 --- a/src/displayapp/screens/WatchFaceInfineat.h +++ b/src/displayapp/screens/WatchFaceInfineat.h @@ -139,6 +139,7 @@ namespace Pinetime { Controllers::MotionController& motionController; void SetBatteryLevel(uint8_t batteryPercent); + void ToggleBatteryIndicatorColor(bool showSideCover); lv_task_t* taskRefresh; };