Skip to content

Commit 65fa72e

Browse files
authored
Merge branch 'main' into feature/fix-step-notification
2 parents 1292ef6 + c0638c6 commit 65fa72e

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

src/displayapp/screens/BatteryInfo.cpp

+23-20
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,35 @@ BatteryInfo::BatteryInfo(const Pinetime::Controllers::Battery& batteryController
1010
batteryPercent = batteryController.PercentRemaining();
1111
batteryVoltage = batteryController.Voltage();
1212

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);
2325

2426
status = lv_label_create(lv_scr_act(), nullptr);
2527
lv_label_set_text_static(status, "Reading Battery status");
2628
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);
2830

2931
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);
3133
lv_label_set_text_fmt(percent, "%02i%%", batteryPercent);
3234
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);
3436

3537
voltage = lv_label_create(lv_scr_act(), nullptr);
3638
lv_obj_set_style_local_text_color(voltage, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
3739
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
3840
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);
4042

4143
taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this);
4244
Refresh();
@@ -53,22 +55,23 @@ void BatteryInfo::Refresh() {
5355
batteryVoltage = batteryController.Voltage();
5456

5557
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);
5759
lv_label_set_text_static(status, "Charging");
5860
} 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);
6062
lv_label_set_text_static(status, "Fully charged");
6163
} 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);
6365
lv_label_set_text_static(status, "Battery low");
6466
} 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);
6668
lv_label_set_text_static(status, "Discharging");
6769
}
6870

6971
lv_label_set_text_fmt(percent, "%02i%%", batteryPercent);
72+
lv_obj_align(percent, chargingArc, LV_ALIGN_CENTER, 0, 0);
7073

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);
7275
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);
7477
}

src/displayapp/screens/BatteryInfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Pinetime {
2424

2525
lv_obj_t* voltage;
2626
lv_obj_t* percent;
27-
lv_obj_t* charging_bar;
27+
lv_obj_t* chargingArc;
2828
lv_obj_t* status;
2929

3030
lv_task_t* taskRefresh;

src/displayapp/screens/SystemInfo.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,12 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
241241
lv_table_set_col_width(infoTask, 3, 90);
242242

243243
auto nb = uxTaskGetSystemState(tasksStatus, maxTaskCount, nullptr);
244+
// g++ emits a spurious warning (and thus error because we compile with -Werror)
245+
// due to the way std::sort is implemented
246+
#pragma GCC diagnostic push
247+
#pragma GCC diagnostic ignored "-Warray-bounds"
244248
std::sort(tasksStatus, tasksStatus + nb, sortById);
249+
#pragma GCC diagnostic pop
245250
for (uint8_t i = 0; i < nb && i < maxTaskCount; i++) {
246251
char buffer[11] = {0};
247252

0 commit comments

Comments
 (0)