55
66using namespace Pinetime ::Applications::Screens;
77
8+ static void lap_event_handler (lv_obj_t * obj, lv_event_t event) {
9+ auto * steps = static_cast <Steps*>(obj->user_data );
10+ steps->lapBtnEventHandler (event);
11+ }
12+
813Steps::Steps (Pinetime::Applications::DisplayApp* app,
914 Controllers::MotionController& motionController,
1015 Controllers::Settings& settingsController)
@@ -17,37 +22,54 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
1722 lv_obj_set_style_local_radius (stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0 );
1823 lv_obj_set_style_local_line_color (stepsArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, lv_color_hex (0x0000FF ));
1924 lv_arc_set_end_angle (stepsArc, 200 );
20- lv_obj_set_size (stepsArc, 220 , 220 );
25+ lv_obj_set_size (stepsArc, 200 , 200 );
2126 lv_arc_set_range (stepsArc, 0 , 500 );
22- lv_obj_align (stepsArc, nullptr , LV_ALIGN_CENTER, 0 , 0 );
27+ lv_obj_align (stepsArc, nullptr , LV_ALIGN_CENTER, 0 , - 20 );
2328
2429 stepsCount = motionController.NbSteps ();
30+ currentLapSteps = stepsCount - motionController.GetPrevTotalSteps ();
2531
2632 lv_arc_set_value (stepsArc, int16_t (500 * stepsCount / settingsController.GetStepsGoal ()));
2733
2834 lSteps = lv_label_create (lv_scr_act (), nullptr );
2935 lv_obj_set_style_local_text_color (lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex (0x00FF00 ));
3036 lv_obj_set_style_local_text_font (lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
31- lv_label_set_text_fmt (lSteps, " %li" , stepsCount );
32- lv_obj_align (lSteps, nullptr , LV_ALIGN_CENTER, 0 , -20 );
37+ lv_label_set_text_fmt (lSteps, " %li" , currentLapSteps );
38+ lv_obj_align (lSteps, nullptr , LV_ALIGN_CENTER, 0 , -40 );
3339
3440 lv_obj_t * lstepsL = lv_label_create (lv_scr_act (), nullptr );
3541 lv_obj_set_style_local_text_color (lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex (0x111111 ));
3642 lv_label_set_text_static (lstepsL, " Steps" );
37- lv_obj_align (lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0 , 10 );
43+ lv_obj_align (lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0 , 5 );
3844
3945 lv_obj_t * lstepsGoal = lv_label_create (lv_scr_act (), nullptr );
4046 lv_obj_set_style_local_text_color (lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
4147 lv_label_set_text_fmt (lstepsGoal, " Goal\n %lu" , settingsController.GetStepsGoal ());
4248 lv_label_set_align (lstepsGoal, LV_LABEL_ALIGN_CENTER);
43- lv_obj_align (lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0 , 60 );
49+ lv_obj_align (lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0 , 30 );
4450
4551 lv_obj_t * backgroundLabel = lv_label_create (lv_scr_act (), nullptr );
4652 lv_label_set_long_mode (backgroundLabel, LV_LABEL_LONG_CROP);
4753 lv_obj_set_size (backgroundLabel, 240 , 240 );
4854 lv_obj_set_pos (backgroundLabel, 0 , 0 );
4955 lv_label_set_text_static (backgroundLabel, " " );
5056
57+ btnLap = lv_btn_create (lv_scr_act (), nullptr );
58+ btnLap->user_data = this ;
59+ lv_obj_set_event_cb (btnLap, lap_event_handler);
60+ lv_obj_set_height (btnLap, 50 );
61+ lv_obj_set_width (btnLap, 115 );
62+ lv_obj_align (btnLap, lv_scr_act (), LV_ALIGN_IN_BOTTOM_LEFT, 0 , 0 );
63+ lv_obj_set_style_local_bg_color (btnLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, lv_color_hex (0x080808 ));
64+ txtLap = lv_label_create (btnLap, nullptr );
65+ lv_obj_set_style_local_text_color (btnLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, lv_color_hex (0x888888 ));
66+ lv_label_set_text (txtLap, Symbols::lapsFlag);
67+
68+ totalStepsText = lv_label_create (lv_scr_act (), nullptr );
69+ lv_obj_set_style_local_text_color (totalStepsText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
70+ lv_label_set_text_fmt (totalStepsText, " Total\n %li" , motionController.GetPrevTotalSteps ());
71+ lv_obj_align (totalStepsText, lv_scr_act (), LV_ALIGN_IN_BOTTOM_RIGHT, 0 , 0 );
72+
5173 taskRefresh = lv_task_create (RefreshTaskCallback, 100 , LV_TASK_PRIO_MID, this );
5274}
5375
@@ -58,9 +80,23 @@ Steps::~Steps() {
5880
5981void Steps::Refresh () {
6082 stepsCount = motionController.NbSteps ();
83+ currentLapSteps = stepsCount - motionController.GetPrevTotalSteps ();
84+
85+ lv_label_set_text_fmt (lSteps, " %li" , currentLapSteps);
86+ lv_obj_align (lSteps, nullptr , LV_ALIGN_CENTER, 0 , -40 );
6187
62- lv_label_set_text_fmt (lSteps , " %li" , stepsCount);
63- lv_obj_align (lSteps, nullptr , LV_ALIGN_CENTER , 0 , - 20 );
88+ lv_label_set_text_fmt (totalStepsText , " Total \n %li" , stepsCount);
89+ lv_obj_align (totalStepsText, lv_scr_act (), LV_ALIGN_IN_BOTTOM_RIGHT , 0 , 0 );
6490
6591 lv_arc_set_value (stepsArc, int16_t (500 * stepsCount / settingsController.GetStepsGoal ()));
6692}
93+
94+ void Steps::lapBtnEventHandler (lv_event_t event) {
95+ if (event != LV_EVENT_CLICKED) {
96+ return ;
97+ }
98+ stepsCount = motionController.NbSteps ();
99+ motionController.SetPrevTotalSteps (stepsCount);
100+ Refresh ();
101+ }
102+
0 commit comments