aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRiku Isokoski <riksu9000@gmail.com>2022-12-31 10:05:38 +0200
committerRiku Isokoski <riksu9000@gmail.com>2023-03-02 13:38:31 +0200
commit08b4cfbb50a5ad7b6d2aebea4ef605165d88832b (patch)
tree4022920609f033d6a281263e9fbe0b40871e7544
parentfff0a00a4a251fafa1c195d9f92fdc07affe3ca2 (diff)
Add low battery indicator to StatusIcons, digital and analog watchfaces
Define deepOrange color in InfiniTimeTheme
-rw-r--r--src/displayapp/InfiniTimeTheme.h1
-rw-r--r--src/displayapp/screens/BatteryIcon.cpp14
-rw-r--r--src/displayapp/screens/BatteryIcon.h2
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.cpp1
-rw-r--r--src/displayapp/screens/WatchFaceCasioStyleG7710.cpp1
-rw-r--r--src/displayapp/screens/WatchFacePineTimeStyle.cpp1
-rw-r--r--src/displayapp/widgets/StatusIcons.cpp2
7 files changed, 21 insertions, 1 deletions
diff --git a/src/displayapp/InfiniTimeTheme.h b/src/displayapp/InfiniTimeTheme.h
index 99313cf0..0690b099 100644
--- a/src/displayapp/InfiniTimeTheme.h
+++ b/src/displayapp/InfiniTimeTheme.h
@@ -3,6 +3,7 @@
#include <lvgl/lvgl.h>
namespace Colors {
+ static constexpr lv_color_t deepOrange = LV_COLOR_MAKE(0xff, 0x40, 0x0);
static constexpr lv_color_t orange = LV_COLOR_MAKE(0xff, 0xb0, 0x0);
static constexpr lv_color_t green = LV_COLOR_MAKE(0x0, 0xb0, 0x0);
static constexpr lv_color_t blue = LV_COLOR_MAKE(0x0, 0x50, 0xff);
diff --git a/src/displayapp/screens/BatteryIcon.cpp b/src/displayapp/screens/BatteryIcon.cpp
index 2fe7c251..6194807d 100644
--- a/src/displayapp/screens/BatteryIcon.cpp
+++ b/src/displayapp/screens/BatteryIcon.cpp
@@ -2,9 +2,12 @@
#include <cstdint>
#include "displayapp/screens/Symbols.h"
#include "displayapp/icons/battery/batteryicon.c"
+#include "displayapp/InfiniTimeTheme.h"
using namespace Pinetime::Applications::Screens;
+BatteryIcon::BatteryIcon(bool colorOnLowBattery) : colorOnLowBattery {colorOnLowBattery} {};
+
void BatteryIcon::Create(lv_obj_t* parent) {
batteryImg = lv_img_create(parent, nullptr);
lv_img_set_src(batteryImg, &batteryicon);
@@ -23,6 +26,17 @@ lv_obj_t* BatteryIcon::GetObject() {
void BatteryIcon::SetBatteryPercentage(uint8_t percentage) {
lv_obj_set_height(batteryJuice, percentage * 14 / 100);
lv_obj_realign(batteryJuice);
+ if (colorOnLowBattery) {
+ static constexpr int lowBatteryThreshold = 15;
+ static constexpr int criticalBatteryThreshold = 5;
+ if (percentage > lowBatteryThreshold) {
+ SetColor(LV_COLOR_WHITE);
+ } else if (percentage > criticalBatteryThreshold) {
+ SetColor(LV_COLOR_ORANGE);
+ } else {
+ SetColor(Colors::deepOrange);
+ }
+ }
}
void BatteryIcon::SetColor(lv_color_t color) {
diff --git a/src/displayapp/screens/BatteryIcon.h b/src/displayapp/screens/BatteryIcon.h
index 45d8f0ef..19fea967 100644
--- a/src/displayapp/screens/BatteryIcon.h
+++ b/src/displayapp/screens/BatteryIcon.h
@@ -7,6 +7,7 @@ namespace Pinetime {
namespace Screens {
class BatteryIcon {
public:
+ explicit BatteryIcon(bool colorOnLowBattery);
void Create(lv_obj_t* parent);
void SetColor(lv_color_t);
@@ -19,6 +20,7 @@ namespace Pinetime {
private:
lv_obj_t* batteryImg;
lv_obj_t* batteryJuice;
+ bool colorOnLowBattery = false;
};
}
}
diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp
index 34b50655..ad66be15 100644
--- a/src/displayapp/screens/WatchFaceAnalog.cpp
+++ b/src/displayapp/screens/WatchFaceAnalog.cpp
@@ -49,6 +49,7 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController)
: currentDateTime {{}},
+ batteryIcon(true),
dateTimeController {dateTimeController},
batteryController {batteryController},
bleController {bleController},
diff --git a/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp b/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp
index 0bfb7193..ca37c8fc 100644
--- a/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp
+++ b/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp
@@ -23,6 +23,7 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTi
Controllers::MotionController& motionController,
Controllers::FS& filesystem)
: currentDateTime {{}},
+ batteryIcon(false),
dateTimeController {dateTimeController},
batteryController {batteryController},
bleController {bleController},
diff --git a/src/displayapp/screens/WatchFacePineTimeStyle.cpp b/src/displayapp/screens/WatchFacePineTimeStyle.cpp
index 19841c15..d1eca286 100644
--- a/src/displayapp/screens/WatchFacePineTimeStyle.cpp
+++ b/src/displayapp/screens/WatchFacePineTimeStyle.cpp
@@ -50,6 +50,7 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
Controllers::Settings& settingsController,
Controllers::MotionController& motionController)
: currentDateTime {{}},
+ batteryIcon(false),
dateTimeController {dateTimeController},
batteryController {batteryController},
bleController {bleController},
diff --git a/src/displayapp/widgets/StatusIcons.cpp b/src/displayapp/widgets/StatusIcons.cpp
index 0202cd85..423b53d9 100644
--- a/src/displayapp/widgets/StatusIcons.cpp
+++ b/src/displayapp/widgets/StatusIcons.cpp
@@ -4,7 +4,7 @@
using namespace Pinetime::Applications::Widgets;
StatusIcons::StatusIcons(const Controllers::Battery& batteryController, const Controllers::Ble& bleController)
- : batteryController {batteryController}, bleController {bleController} {
+ : batteryIcon(true), batteryController {batteryController}, bleController {bleController} {
}
void StatusIcons::Create() {