@@ -24,24 +24,23 @@ BatteryInfo::BatteryInfo(const Pinetime::Controllers::Battery& batteryController
2424 lv_obj_set_style_local_line_color (chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_LIME);
2525
2626 status = lv_label_create (lv_scr_act (), nullptr );
27- lv_label_set_text_static (status, " Reading Battery status" );
2827 lv_label_set_align (status, LV_LABEL_ALIGN_CENTER);
29- lv_obj_align (status, nullptr , LV_ALIGN_IN_BOTTOM_MID, 0 , -17 );
28+ lv_obj_align (status, voltage, LV_ALIGN_IN_BOTTOM_MID, 0 , -27 );
29+ lv_obj_set_auto_realign (status, true );
3030
3131 percent = lv_label_create (lv_scr_act (), nullptr );
3232 lv_obj_set_style_local_text_font (percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
33- lv_label_set_text_fmt (percent, " %i%%" , batteryPercent);
3433 lv_label_set_align (percent, LV_LABEL_ALIGN_LEFT);
3534 lv_obj_align (percent, chargingArc, LV_ALIGN_CENTER, 0 , 0 );
35+ lv_obj_set_auto_realign (percent, true );
3636
3737 voltage = lv_label_create (lv_scr_act (), nullptr );
3838 lv_obj_set_style_local_text_color (voltage, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
39- lv_label_set_text_fmt (voltage, " %1i.%02i volts" , batteryVoltage / 1000 , batteryVoltage % 1000 / 10 );
4039 lv_label_set_align (voltage, LV_LABEL_ALIGN_CENTER);
4140 lv_obj_align (voltage, nullptr , LV_ALIGN_IN_BOTTOM_MID, 0 , -7 );
4241
43- taskRefresh = lv_task_create (RefreshTaskCallback, 5000 , LV_TASK_PRIO_MID, this );
4442 Refresh ();
43+ taskRefresh = lv_task_create (RefreshTaskCallback, 5000 , LV_TASK_PRIO_MID, this );
4544}
4645
4746BatteryInfo::~BatteryInfo () {
@@ -72,9 +71,6 @@ void BatteryInfo::Refresh() {
7271 }
7372
7473 lv_label_set_text_fmt (percent, " %i%%" , batteryPercent);
75- lv_obj_align (percent, chargingArc, LV_ALIGN_CENTER, 0 , 0 );
76-
77- lv_obj_align (status, voltage, LV_ALIGN_IN_BOTTOM_MID, 0 , -27 );
7874 lv_label_set_text_fmt (voltage, " %1i.%02i volts" , batteryVoltage / 1000 , batteryVoltage % 1000 / 10 );
7975 lv_arc_set_value (chargingArc, batteryPercent);
8076}
0 commit comments