InfiniTime.git

ref: 0195ece317d15bcba7dfbd74b58bb8dbcd3bca0a

src/DisplayApp/Screens/BatteryIcon.cpp


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "BatteryIcon.h"

using namespace Pinetime::Applications::Screens;


extern lv_img_dsc_t ck_os_battery_error;
extern lv_img_dsc_t ck_os_batterycharging_100;
extern lv_img_dsc_t ck_os_batterycharging_090;
extern lv_img_dsc_t ck_os_batterycharging_080;
extern lv_img_dsc_t ck_os_batterycharging_070;
extern lv_img_dsc_t ck_os_batterycharging_060;
extern lv_img_dsc_t ck_os_batterycharging_050;
extern lv_img_dsc_t ck_os_batterycharging_040;
extern lv_img_dsc_t ck_os_batterycharging_030;
extern lv_img_dsc_t ck_os_batterycharging_020;
extern lv_img_dsc_t ck_os_batterycharging_010;
extern lv_img_dsc_t ck_os_batterycharging_005;

extern lv_img_dsc_t ck_os_battery_100;
extern lv_img_dsc_t ck_os_battery_090;
extern lv_img_dsc_t ck_os_battery_080;
extern lv_img_dsc_t ck_os_battery_070;
extern lv_img_dsc_t ck_os_battery_060;
extern lv_img_dsc_t ck_os_battery_050;
extern lv_img_dsc_t ck_os_battery_040;
extern lv_img_dsc_t ck_os_battery_030;
extern lv_img_dsc_t ck_os_battery_020;
extern lv_img_dsc_t ck_os_battery_010;
extern lv_img_dsc_t ck_os_battery_005;


lv_img_dsc_t *BatteryIcon::GetIcon(bool isCharging, float batteryPercent) {
  if(isCharging) {
    if(batteryPercent > 90.0f) return &ck_os_batterycharging_100;
    else if(batteryPercent > 80.0f) return &ck_os_batterycharging_090;
    else if(batteryPercent > 70.0f) return &ck_os_batterycharging_080;
    else if(batteryPercent > 60.0f) return &ck_os_batterycharging_070;
    else if(batteryPercent > 50.0f) return &ck_os_batterycharging_060;
    else if(batteryPercent > 40.0f) return &ck_os_batterycharging_050;
    else if(batteryPercent > 30.0f) return &ck_os_batterycharging_040;
    else if(batteryPercent > 20.0f) return &ck_os_batterycharging_030;
    else if(batteryPercent > 10.0f) return &ck_os_batterycharging_020;
    else if(batteryPercent > 5.0f) return &ck_os_batterycharging_010;
    else return &ck_os_batterycharging_005;
  } else {
    if(batteryPercent > 90.0f) return &ck_os_battery_100;
    else if(batteryPercent > 80.0f) return &ck_os_battery_090;
    else if(batteryPercent > 70.0f) return &ck_os_battery_080;
    else if(batteryPercent > 60.0f) return &ck_os_battery_070;
    else if(batteryPercent > 50.0f) return &ck_os_battery_060;
    else if(batteryPercent > 40.0f) return &ck_os_battery_050;
    else if(batteryPercent > 30.0f) return &ck_os_battery_040;
    else if(batteryPercent > 20.0f) return &ck_os_battery_030;
    else if(batteryPercent > 10.0f) return &ck_os_battery_020;
    else if(batteryPercent > 5.0f) return &ck_os_battery_010;
    else return &ck_os_battery_005;
  }
}

lv_img_dsc_t *BatteryIcon::GetUnknownIcon() {
  return &ck_os_battery_error;
}