diff options
| author | Riku Isokoski <riksu9000@gmail.com> | 2022-04-07 14:28:04 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-06-06 05:32:21 (GMT) |
| commit | fab003528965668e2855491b36b5ba553c6a52f5 (patch) | |
| tree | 03cb04e9813b381ef7626970d549b58191f379d4 /src/displayapp/screens/BatteryIcon.cpp | |
| parent | fbfb8fa4a2ca9274c73f2ba2e6cec4b8fc9e8ad4 (diff) | |
New sharper batteryicon. Remove old unused batteryicons
Diffstat (limited to 'src/displayapp/screens/BatteryIcon.cpp')
| -rw-r--r-- | src/displayapp/screens/BatteryIcon.cpp | 35 |
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) { |
