@@ -10,33 +10,35 @@ BatteryInfo::BatteryInfo(const Pinetime::Controllers::Battery& batteryController
10
10
batteryPercent = batteryController.PercentRemaining ();
11
11
batteryVoltage = batteryController.Voltage ();
12
12
13
- charging_bar = lv_bar_create (lv_scr_act (), nullptr );
14
- lv_obj_set_size (charging_bar, 200 , 15 );
15
- lv_bar_set_range (charging_bar, 0 , 100 );
16
- lv_obj_align (charging_bar, nullptr , LV_ALIGN_CENTER, 0 , 10 );
17
- lv_bar_set_anim_time (charging_bar, 1000 );
18
- lv_obj_set_style_local_radius (charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
19
- lv_obj_set_style_local_bg_color (charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, Colors::bgAlt);
20
- lv_obj_set_style_local_bg_opa (charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_OPA_100);
21
- lv_obj_set_style_local_bg_color (charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
22
- lv_bar_set_value (charging_bar, batteryPercent, LV_ANIM_ON);
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);
23
25
24
26
status = lv_label_create (lv_scr_act (), nullptr );
25
27
lv_label_set_text_static (status, " Reading Battery status" );
26
28
lv_label_set_align (status, LV_LABEL_ALIGN_CENTER);
27
- lv_obj_align (status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID , 0 , 20 );
29
+ lv_obj_align (status, nullptr , LV_ALIGN_IN_BOTTOM_MID , 0 , - 17 );
28
30
29
31
percent = lv_label_create (lv_scr_act (), nullptr );
30
- lv_obj_set_style_local_text_font (percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76 );
32
+ lv_obj_set_style_local_text_font (percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42 );
31
33
lv_label_set_text_fmt (percent, " %02i%%" , batteryPercent);
32
34
lv_label_set_align (percent, LV_LABEL_ALIGN_LEFT);
33
- lv_obj_align (percent, nullptr , LV_ALIGN_CENTER, 0 , - 60 );
35
+ lv_obj_align (percent, chargingArc , LV_ALIGN_CENTER, 0 , 0 );
34
36
35
37
voltage = lv_label_create (lv_scr_act (), nullptr );
36
38
lv_obj_set_style_local_text_color (voltage, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
37
39
lv_label_set_text_fmt (voltage, " %1i.%02i volts" , batteryVoltage / 1000 , batteryVoltage % 1000 / 10 );
38
40
lv_label_set_align (voltage, LV_LABEL_ALIGN_CENTER);
39
- lv_obj_align (voltage, nullptr , LV_ALIGN_CENTER , 0 , 95 );
41
+ lv_obj_align (voltage, nullptr , LV_ALIGN_IN_BOTTOM_MID , 0 , - 7 );
40
42
41
43
taskRefresh = lv_task_create (RefreshTaskCallback, 5000 , LV_TASK_PRIO_MID, this );
42
44
Refresh ();
@@ -53,22 +55,23 @@ void BatteryInfo::Refresh() {
53
55
batteryVoltage = batteryController.Voltage ();
54
56
55
57
if (batteryController.IsCharging ()) {
56
- lv_obj_set_style_local_bg_color (charging_bar, LV_BAR_PART_INDIC , LV_STATE_DEFAULT, LV_COLOR_RED );
58
+ lv_obj_set_style_local_line_color (chargingArc, LV_ARC_PART_INDIC , LV_STATE_DEFAULT, LV_COLOR_LIME );
57
59
lv_label_set_text_static (status, " Charging" );
58
60
} else if (batteryPercent == 100 ) {
59
- lv_obj_set_style_local_bg_color (charging_bar, LV_BAR_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);
60
62
lv_label_set_text_static (status, " Fully charged" );
61
63
} else if (batteryPercent < 10 ) {
62
- lv_obj_set_style_local_bg_color (charging_bar, LV_BAR_PART_INDIC , LV_STATE_DEFAULT, LV_COLOR_YELLOW );
64
+ lv_obj_set_style_local_line_color (chargingArc, LV_ARC_PART_INDIC , LV_STATE_DEFAULT, LV_COLOR_RED );
63
65
lv_label_set_text_static (status, " Battery low" );
64
66
} else {
65
- lv_obj_set_style_local_bg_color (charging_bar, LV_BAR_PART_INDIC , LV_STATE_DEFAULT, Colors::highlight );
67
+ lv_obj_set_style_local_line_color (chargingArc, LV_ARC_PART_INDIC , LV_STATE_DEFAULT, LV_COLOR_GREEN );
66
68
lv_label_set_text_static (status, " Discharging" );
67
69
}
68
70
69
71
lv_label_set_text_fmt (percent, " %02i%%" , batteryPercent);
72
+ lv_obj_align (percent, chargingArc, LV_ALIGN_CENTER, 0 , 0 );
70
73
71
- lv_obj_align (status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID , 0 , 20 );
74
+ lv_obj_align (status, voltage, LV_ALIGN_IN_BOTTOM_MID , 0 , - 27 );
72
75
lv_label_set_text_fmt (voltage, " %1i.%02i volts" , batteryVoltage / 1000 , batteryVoltage % 1000 / 10 );
73
- lv_bar_set_value (charging_bar , batteryPercent, LV_ANIM_ON );
76
+ lv_arc_set_value (chargingArc , batteryPercent);
74
77
}
0 commit comments