@@ -10,18 +10,18 @@ BatteryInfo::BatteryInfo(const Pinetime::Controllers::Battery& batteryController
10
10
batteryPercent = batteryController.PercentRemaining ();
11
11
batteryVoltage = batteryController.Voltage ();
12
12
13
- charging_arc = lv_arc_create (lv_scr_act (), nullptr );
14
- lv_arc_set_rotation (charging_arc , 270 );
15
- lv_arc_set_bg_angles (charging_arc , 0 , 360 );
16
- lv_arc_set_adjustable (charging_arc , false );
17
- lv_obj_set_size (charging_arc , 180 , 180 );
18
- lv_obj_align (charging_arc , nullptr , LV_ALIGN_CENTER, 0 , -30 );
19
- lv_arc_set_value (charging_arc , batteryPercent);
20
- lv_obj_set_style_local_bg_opa (charging_arc , LV_ARC_PART_BG, LV_STATE_DEFAULT, LV_OPA_0);
21
- lv_obj_set_style_local_line_color (charging_arc , LV_ARC_PART_BG, LV_STATE_DEFAULT, Colors::bgAlt);
22
- lv_obj_set_style_local_border_width (charging_arc , LV_ARC_PART_BG, LV_STATE_DEFAULT, 2 );
23
- lv_obj_set_style_local_radius (charging_arc , LV_ARC_PART_BG, LV_STATE_DEFAULT, 0 );
24
- lv_obj_set_style_local_line_color (charging_arc , LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_LIME);
13
+ chargingArc = lv_arc_create (lv_scr_act (), nullptr );
14
+ lv_arc_set_rotation (chargingArc , 270 );
15
+ lv_arc_set_bg_angles (chargingArc , 0 , 360 );
16
+ lv_arc_set_adjustable (chargingArc , false );
17
+ lv_obj_set_size (chargingArc , 180 , 180 );
18
+ lv_obj_align (chargingArc , nullptr , LV_ALIGN_CENTER, 0 , -30 );
19
+ lv_arc_set_value (chargingArc , batteryPercent);
20
+ lv_obj_set_style_local_bg_opa (chargingArc , LV_ARC_PART_BG, LV_STATE_DEFAULT, LV_OPA_0);
21
+ lv_obj_set_style_local_line_color (chargingArc , LV_ARC_PART_BG, LV_STATE_DEFAULT, Colors::bgAlt);
22
+ lv_obj_set_style_local_border_width (chargingArc , LV_ARC_PART_BG, LV_STATE_DEFAULT, 2 );
23
+ lv_obj_set_style_local_radius (chargingArc , LV_ARC_PART_BG, LV_STATE_DEFAULT, 0 );
24
+ lv_obj_set_style_local_line_color (chargingArc , LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_LIME);
25
25
26
26
status = lv_label_create (lv_scr_act (), nullptr );
27
27
lv_label_set_text_static (status, " Reading Battery status" );
@@ -32,7 +32,7 @@ BatteryInfo::BatteryInfo(const Pinetime::Controllers::Battery& batteryController
32
32
lv_obj_set_style_local_text_font (percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
33
33
lv_label_set_text_fmt (percent, " %02i%%" , batteryPercent);
34
34
lv_label_set_align (percent, LV_LABEL_ALIGN_LEFT);
35
- lv_obj_align (percent, charging_arc , LV_ALIGN_CENTER, 0 , 0 );
35
+ lv_obj_align (percent, chargingArc , LV_ALIGN_CENTER, 0 , 0 );
36
36
37
37
voltage = lv_label_create (lv_scr_act (), nullptr );
38
38
lv_obj_set_style_local_text_color (voltage, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
@@ -52,25 +52,26 @@ BatteryInfo::~BatteryInfo() {
52
52
void BatteryInfo::Refresh () {
53
53
54
54
batteryPercent = batteryController.PercentRemaining ();
55
+ batteryVoltage = batteryController.Voltage ();
55
56
56
57
if (batteryController.IsCharging ()) {
57
- lv_obj_set_style_local_line_color (charging_arc , LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_LIME);
58
+ lv_obj_set_style_local_line_color (chargingArc , LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_LIME);
58
59
lv_label_set_text_static (status, " Charging" );
59
60
} else if (batteryPercent == 100 ) {
60
- lv_obj_set_style_local_line_color (charging_arc , LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLUE);
61
+ lv_obj_set_style_local_line_color (chargingArc , LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLUE);
61
62
lv_label_set_text_static (status, " Fully charged" );
62
63
} else if (batteryPercent < 10 ) {
63
- lv_obj_set_style_local_line_color (charging_arc , LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
64
+ lv_obj_set_style_local_line_color (chargingArc , LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
64
65
lv_label_set_text_static (status, " Battery low" );
65
66
} else {
66
- lv_obj_set_style_local_line_color (charging_arc , LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_GREEN);
67
+ lv_obj_set_style_local_line_color (chargingArc , LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_GREEN);
67
68
lv_label_set_text_static (status, " Discharging" );
68
69
}
69
70
70
71
lv_label_set_text_fmt (percent, " %02i%%" , batteryPercent);
71
- lv_obj_align (percent, charging_arc , LV_ALIGN_CENTER, 0 , 0 );
72
+ lv_obj_align (percent, chargingArc , LV_ALIGN_CENTER, 0 , 0 );
72
73
73
74
lv_obj_align (status, voltage, LV_ALIGN_IN_BOTTOM_MID, 0 , -27 );
74
75
lv_label_set_text_fmt (voltage, " %1i.%02i volts" , batteryVoltage / 1000 , batteryVoltage % 1000 / 10 );
75
- lv_arc_set_value (charging_arc , batteryPercent);
76
+ lv_arc_set_value (chargingArc , batteryPercent);
76
77
}
0 commit comments