@@ -9,11 +9,6 @@ static void lv_update_task(struct _lv_task_t* task) {
99 user_data->UpdateScreen ();
1010}
1111
12- static void lv_anim_task (struct _lv_task_t * task) {
13- auto user_data = static_cast <BatteryInfo*>(task->user_data );
14- user_data->UpdateAnim ();
15- }
16-
1712BatteryInfo::BatteryInfo (Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Battery& batteryController)
1813 : Screen(app), batteryController {batteryController} {
1914
@@ -24,12 +19,12 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
2419 lv_obj_set_size (charging_bar, 200 , 15 );
2520 lv_bar_set_range (charging_bar, 0 , 100 );
2621 lv_obj_align (charging_bar, nullptr , LV_ALIGN_CENTER, 0 , 10 );
27- lv_bar_set_anim_time (charging_bar, 2000 );
22+ lv_bar_set_anim_time (charging_bar, 1000 );
2823 lv_obj_set_style_local_radius (charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
2924 lv_obj_set_style_local_bg_color (charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, lv_color_hex (0x222222 ));
3025 lv_obj_set_style_local_bg_opa (charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_OPA_100);
3126 lv_obj_set_style_local_bg_color (charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, lv_color_hex (0xFF0000 ));
32- lv_bar_set_value (charging_bar, batteryPercent, LV_ANIM_OFF );
27+ lv_bar_set_value (charging_bar, batteryPercent, LV_ANIM_ON );
3328
3429 status = lv_label_create (lv_scr_act (), nullptr );
3530 lv_label_set_text_static (status, " Reading Battery status" );
@@ -54,38 +49,15 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
5449 lv_obj_set_pos (backgroundLabel, 0 , 0 );
5550 lv_label_set_text_static (backgroundLabel, " " );
5651
57- taskUpdate = lv_task_create (lv_update_task, 500000 , LV_TASK_PRIO_LOW, this );
58- taskAnim = lv_task_create (lv_anim_task, 1000 , LV_TASK_PRIO_LOW, this );
52+ taskUpdate = lv_task_create (lv_update_task, 5000 , LV_TASK_PRIO_LOW, this );
5953 UpdateScreen ();
6054}
6155
6256BatteryInfo::~BatteryInfo () {
6357 lv_task_del (taskUpdate);
64- lv_task_del (taskAnim);
6558 lv_obj_clean (lv_scr_act ());
6659}
6760
68- void BatteryInfo::UpdateAnim () {
69- batteryPercent = batteryController.PercentRemaining ();
70-
71- if (batteryController.IsCharging () and batteryPercent < 100 ) {
72- animation += 1 ;
73- if (animation >= 100 ) {
74- animation = 0 ;
75- }
76-
77- } else {
78- if (animation > batteryPercent) {
79- animation--;
80- }
81- if (animation < batteryPercent) {
82- animation++;
83- }
84- }
85-
86- lv_bar_set_value (charging_bar, animation, LV_ANIM_OFF);
87- }
88-
8961void BatteryInfo::UpdateScreen () {
9062
9163 batteryController.Update ();
@@ -111,9 +83,9 @@ void BatteryInfo::UpdateScreen() {
11183
11284 lv_obj_align (status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID, 0 , 20 );
11385 lv_label_set_text_fmt (voltage, " %1i.%02i volts" , batteryVoltage / 1000 , batteryVoltage % 1000 / 10 );
86+ lv_bar_set_value (charging_bar, batteryPercent, LV_ANIM_ON);
11487}
11588
11689bool BatteryInfo::Refresh () {
117-
11890 return running;
11991}
0 commit comments