@@ -10,14 +10,35 @@ using namespace Pinetime::Applications::Screens;
1010HeartRateZone::HeartRateZone (Controllers::HeartRateController& heartRateController, System::SystemTask& systemTask)
1111 : heartRateController {heartRateController}, wakeLock(systemTask) {
1212 auto activity = heartRateController.Activity ();
13+ auto settings = heartRateController.hrzSettings ();
1314 uint32_t total = 0 ;
1415
15- auto hundreths_of_hour = pdMS_TO_TICKS (10 *60 *60 );
16+ auto hundreths_of_hour = pdMS_TO_TICKS (10 * 60 * 60 );
17+ auto exercise_target = pdMS_TO_TICKS (settings.exerciseMsTarget );
18+ uint32_t offset = 25 * (zone_bar.size () + 2 );
1619
1720 lv_obj_t * screen = lv_scr_act ();
21+
22+ title = lv_label_create (screen);
23+ lv_label_set_text_static (title, " BPM Breakdown" );
24+ lv_obj_align (title, screen, LV_ALIGN_IN_TOP_MID, 0 , 20 );
25+
26+ total_bar = lv_bar_create (screen, nullptr );
27+ lv_obj_set_style_local_bg_opa (zone_bar[i], LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_OPA_0);
28+ lv_obj_set_style_local_line_color (zone_bar[i], LV_BAR_PART_BG, LV_STATE_DEFAULT, Colors::bgAlt);
29+ lv_obj_set_style_local_border_width (zone_bar[i], LV_BAR_PART_BG, LV_STATE_DEFAULT, 2 );
30+ lv_obj_set_style_local_radius (zone_bar[i], LV_BAR_PART_BG, LV_STATE_DEFAULT, 0 );
31+ lv_obj_set_style_local_line_color (zone_bar[0 ], LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_NAVY);
32+
33+ lv_obj_align (total_bar, screen, LV_ALIGN_IN_TOP_MID, 0 , offset - (zone_bar.size () * 25 ));
34+
35+ total_label = lv_label_create (zone_bar[i], nullptr );
36+ lv_obj_align (total_label, zone_bar[i], LV_ALIGN_CENTER, 0 , 0 );
37+ lv_obj_set_style_local_text_color (total_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
38+
1839 for (uint8_t i = 0 ; i < zone_bar.size (); i++) {
1940 zone_bar[i] = lv_bar_create (screen, nullptr );
20-
41+
2142 total += activity.zoneTime [i];
2243
2344 lv_obj_set_style_local_bg_opa (zone_bar[i], LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_OPA_0);
@@ -26,9 +47,9 @@ HeartRateZone::HeartRateZone(Controllers::HeartRateController& heartRateControll
2647 lv_obj_set_style_local_radius (zone_bar[i], LV_BAR_PART_BG, LV_STATE_DEFAULT, 0 );
2748
2849 lv_obj_set_size (zone_bar[i], 240 , 20 );
29- lv_obj_align (zone_bar[i], screen, LV_ALIGN_IN_TOP_MID, 0 , 25 * i );
50+ lv_obj_align (zone_bar[i], screen, LV_ALIGN_IN_TOP_MID, 0 , offset - i * 25 );
3051
31- label_time[i] = lv_label_create (zone_bar[i],nullptr );
52+ label_time[i] = lv_label_create (zone_bar[i], nullptr );
3253 lv_obj_align (label_time[i], zone_bar[i], LV_ALIGN_CENTER, 0 , 0 );
3354
3455 lv_obj_set_style_local_text_color (label_time[i], LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
@@ -39,6 +60,7 @@ HeartRateZone::HeartRateZone(Controllers::HeartRateController& heartRateControll
3960 lv_label_set_text_static (label_time[2 ], " Aerobic" );
4061 lv_label_set_text_static (label_time[3 ], " Threshold" );
4162 lv_label_set_text_static (label_time[4 ], " Anaerobic" );
63+ lv_label_set_text_static (total_label, " Goal" );
4264
4365 lv_obj_set_style_local_line_color (zone_bar[0 ], LV_BAR_PART_INDIC, LV_STATE_DEFAULT, Colors::blue);
4466 lv_obj_set_style_local_line_color (zone_bar[1 ], LV_BAR_PART_INDIC, LV_STATE_DEFAULT, Colors::green);
@@ -54,6 +76,9 @@ HeartRateZone::HeartRateZone(Controllers::HeartRateController& heartRateControll
5476 lv_bar_set_value (zone_bar[i], percent, LV_ANIM_OFF);
5577 }
5678
79+ lv_bar_set_range (total_bar, 0 , exercise_target);
80+ lv_bar_set_value (total_bar, total > exercise_target ? exercise_target : total, LV_ANIM_OFF);
81+
5782 taskRefresh = lv_task_create (RefreshTaskCallback, 5000 , LV_TASK_PRIO_MID, this );
5883}
5984
@@ -79,4 +104,7 @@ void HeartRateZone::Refresh() {
79104 lv_bar_set_range (zone_bar[i], 0 , bar_limit);
80105 lv_bar_set_value (zone_bar[i], percent, LV_ANIM_OFF);
81106 }
107+
108+ lv_bar_set_range (total_bar, 0 , exercise_target);
109+ lv_bar_set_value (total_bar, total > exercise_target ? exercise_target : total, LV_ANIM_OFF);
82110}
0 commit comments