Skip to content

Commit db6ea32

Browse files
committed
Add Step Goal as Dirty Value
1 parent d47197e commit db6ea32

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

src/displayapp/screens/Steps.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ Steps::Steps(Controllers::MotionController& motionController, Controllers::Setti
4444
lv_obj_align(lStepsYesterday, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
4545
lv_obj_set_auto_realign(lStepsYesterday, true);
4646

47-
lv_obj_t* lstepsGoal = lv_label_create(lv_scr_act(), nullptr);
48-
lv_obj_set_style_local_text_color(lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
49-
lv_label_set_text_fmt(lstepsGoal, "Goal: %5lu", settingsController.GetStepsGoal());
50-
lv_label_set_align(lstepsGoal, LV_LABEL_ALIGN_CENTER);
51-
lv_obj_align(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
47+
lStepsGoal = lv_label_create(lv_scr_act(), nullptr);
48+
lv_obj_set_style_local_text_color(lStepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
49+
lv_label_set_align(lStepsGoal, LV_LABEL_ALIGN_CENTER);
50+
lv_obj_align(lStepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
51+
lv_obj_set_auto_realign(lStepsGoal, true);
5252

5353
resetBtn = lv_btn_create(lv_scr_act(), nullptr);
5454
resetBtn->user_data = this;
@@ -62,7 +62,8 @@ Steps::Steps(Controllers::MotionController& motionController, Controllers::Setti
6262

6363
tripLabel = lv_label_create(lv_scr_act(), nullptr);
6464
lv_obj_set_style_local_text_color(tripLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
65-
lv_obj_align(tripLabel, lstepsGoal, LV_ALIGN_IN_LEFT_MID, 0, 20);
65+
lv_obj_align(tripLabel, lStepsGoal, LV_ALIGN_IN_LEFT_MID, 0, 20);
66+
lv_obj_set_auto_realign(tripLabel, true);
6667

6768
Refresh();
6869
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
@@ -76,14 +77,16 @@ Steps::~Steps() {
7677
void Steps::Refresh() {
7778
stepsCount = motionController.NbSteps();
7879
currentTripSteps = motionController.GetTripSteps();
80+
stepsGoal = settingsController.GetStepsGoal();
7981

80-
if (stepsCount.IsUpdated()) {
82+
if (stepsCount.IsUpdated() || stepsGoal.IsUpdated()) {
8183
lv_label_set_text_fmt(lSteps, "%lu", stepsCount.Get());
84+
lv_label_set_text_fmt(lStepsGoal, "Goal: %5lu", stepsGoal.Get());
8285
lv_label_set_text_fmt(lStepsYesterday, "Yest: %5lu", motionController.NbSteps(Days::Yesterday));
83-
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount.Get() / settingsController.GetStepsGoal()));
86+
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount.Get() / stepsGoal.Get()));
8487
}
8588

86-
if (currentTripSteps.IsUpdated()) { // Can be because of Reset button pressed
89+
if (currentTripSteps.IsUpdated()) {
8790
if (currentTripSteps.Get() < 100000) {
8891
lv_label_set_text_fmt(tripLabel, "Trip: %5li", currentTripSteps.Get());
8992
} else {

src/displayapp/screens/Steps.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@ namespace Pinetime {
3131
Controllers::Settings& settingsController;
3232

3333
Utility::DirtyValue<uint32_t> currentTripSteps {};
34+
Utility::DirtyValue<uint32_t> stepsCount {};
35+
Utility::DirtyValue<uint32_t> stepsGoal {};
3436

3537
lv_obj_t* lSteps;
3638
lv_obj_t* lStepsYesterday;
39+
lv_obj_t* lStepsGoal;
3740
lv_obj_t* stepsArc;
3841
lv_obj_t* resetBtn;
3942
lv_obj_t* resetButtonLabel;
4043
lv_obj_t* tripLabel;
4144

42-
Utility::DirtyValue<uint32_t> stepsCount {};
43-
4445
lv_task_t* taskRefresh;
4546
};
4647
}

0 commit comments

Comments
 (0)