|
|
|
@ -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) {
|
|
|
|
|