summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/BatteryIcon.cpp
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-06-06 18:27:54 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-06-06 23:09:58 (GMT)
commit7c45f185a32c7bcff47c8fda1acdec82d3213717 (patch)
tree53b0419fe2a19e6ec5c89d0be0a11dcd8d4ceb00 /src/displayapp/screens/BatteryIcon.cpp
parent94b1b330fc1f6e941a797fedabade4e790e28bc2 (diff)
parent35dcf8c8607483c104711c9398d47d57147f4389 (diff)
Merge remote-tracking branch 'origin/develop' into analog24
Diffstat (limited to 'src/displayapp/screens/BatteryIcon.cpp')
-rw-r--r--src/displayapp/screens/BatteryIcon.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/displayapp/screens/BatteryIcon.cpp b/src/displayapp/screens/BatteryIcon.cpp
index 08aaab7..2fe7c25 100644
--- a/src/displayapp/screens/BatteryIcon.cpp
+++ b/src/displayapp/screens/BatteryIcon.cpp
@@ -1,23 +1,34 @@
#include "displayapp/screens/BatteryIcon.h"
#include <cstdint>
#include "displayapp/screens/Symbols.h"
+#include "displayapp/icons/battery/batteryicon.c"
using namespace Pinetime::Applications::Screens;
-const char* BatteryIcon::GetBatteryIcon(uint8_t batteryPercent) {
- if (batteryPercent > 87)
- return Symbols::batteryFull;
- if (batteryPercent > 62)
- return Symbols::batteryThreeQuarter;
- if (batteryPercent > 37)
- return Symbols::batteryHalf;
- if (batteryPercent > 12)
- return Symbols::batteryOneQuarter;
- return Symbols::batteryEmpty;
+void BatteryIcon::Create(lv_obj_t* parent) {
+ batteryImg = lv_img_create(parent, nullptr);
+ lv_img_set_src(batteryImg, &batteryicon);
+ lv_obj_set_style_local_image_recolor(batteryImg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+
+ batteryJuice = lv_obj_create(batteryImg, nullptr);
+ lv_obj_set_width(batteryJuice, 8);
+ lv_obj_align(batteryJuice, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, -2, -2);
+ lv_obj_set_style_local_radius(batteryJuice, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0);
+}
+
+lv_obj_t* BatteryIcon::GetObject() {
+ return batteryImg;
+}
+
+void BatteryIcon::SetBatteryPercentage(uint8_t percentage) {
+ lv_obj_set_height(batteryJuice, percentage * 14 / 100);
+ lv_obj_realign(batteryJuice);
}
-const char* BatteryIcon::GetUnknownIcon() {
- return Symbols::batteryEmpty;
+void BatteryIcon::SetColor(lv_color_t color) {
+ lv_obj_set_style_local_image_recolor(batteryImg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, color);
+ lv_obj_set_style_local_image_recolor_opa(batteryImg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
+ lv_obj_set_style_local_bg_color(batteryJuice, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, color);
}
const char* BatteryIcon::GetPlugIcon(bool isCharging) {