2021-10-13 16:08:35 -04:00
|
|
|
#include "displayapp/screens/BatteryIcon.h"
|
2021-11-05 18:55:34 -04:00
|
|
|
#include <cstdint>
|
2021-10-13 16:08:35 -04:00
|
|
|
#include "displayapp/screens/Symbols.h"
|
2022-04-07 10:28:04 -04:00
|
|
|
#include "displayapp/icons/battery/batteryicon.c"
|
2020-11-15 10:49:36 -05:00
|
|
|
|
2020-03-14 11:33:47 -04:00
|
|
|
using namespace Pinetime::Applications::Screens;
|
|
|
|
|
2022-04-07 10:28:04 -04:00
|
|
|
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);
|
2020-07-04 07:58:15 -04:00
|
|
|
}
|
2020-03-14 11:33:47 -04:00
|
|
|
|
2022-04-07 10:28:04 -04:00
|
|
|
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);
|
2020-03-14 11:33:47 -04:00
|
|
|
}
|
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
const char* BatteryIcon::GetPlugIcon(bool isCharging) {
|
|
|
|
if (isCharging)
|
2020-07-04 07:58:15 -04:00
|
|
|
return Symbols::plug;
|
2021-04-18 13:28:14 -04:00
|
|
|
else
|
|
|
|
return "";
|
2020-03-14 11:33:47 -04:00
|
|
|
}
|