aboutsummaryrefslogtreecommitdiffstats
path: root/src/displayapp/screens
diff options
context:
space:
mode:
authorHunman <sanyi.exe@gmail.com>2025-11-08 21:58:23 +0100
committerGitHub <noreply@github.com>2025-11-08 20:58:23 +0000
commit716deff7d0456cdd9eb1d152d3b29f1f39c7a231 (patch)
tree8cb2e940071bf3a0db4219b326038ad85b30be68 /src/displayapp/screens
parent9093d18efc1df0be5366444fd72129dae19b2f20 (diff)
Step counter history
Store 2 days steps history and display yesterday's steps on the Steps screen
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/Steps.cpp21
-rw-r--r--src/displayapp/screens/Steps.h1
2 files changed, 19 insertions, 3 deletions
diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp
index c5faaf05..2e73dab5 100644
--- a/src/displayapp/screens/Steps.cpp
+++ b/src/displayapp/screens/Steps.cpp
@@ -5,6 +5,12 @@
using namespace Pinetime::Applications::Screens;
+using Days = Pinetime::Controllers::MotionController::Days;
+
+namespace {
+ constexpr const char* yesterdayStr = "Yest: %5lu";
+}
+
static void lap_event_handler(lv_obj_t* obj, lv_event_t event) {
auto* steps = static_cast<Steps*>(obj->user_data);
steps->lapBtnEventHandler(event);
@@ -33,13 +39,19 @@ Steps::Steps(Controllers::MotionController& motionController, Controllers::Setti
lSteps = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_LIME);
lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
- lv_label_set_text_fmt(lSteps, "%li", stepsCount);
+ lv_label_set_text_fmt(lSteps, "%lu", stepsCount);
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40);
lv_obj_t* lstepsL = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
lv_label_set_text_static(lstepsL, "Steps");
- lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
+ lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
+
+ lStepsYesterday = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(lStepsYesterday, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
+ lv_label_set_text_fmt(lStepsYesterday, yesterdayStr, motionController.NbSteps(Days::Yesterday));
+ lv_label_set_align(lStepsYesterday, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(lStepsYesterday, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
lv_obj_t* lstepsGoal = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
@@ -76,7 +88,10 @@ void Steps::Refresh() {
stepsCount = motionController.NbSteps();
currentTripSteps = motionController.GetTripSteps();
- lv_label_set_text_fmt(lSteps, "%li", stepsCount);
+ lv_label_set_text_fmt(lSteps, "%lu", stepsCount);
+ lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40);
+
+ lv_label_set_text_fmt(lStepsYesterday, yesterdayStr, motionController.NbSteps(Days::Yesterday));
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40);
if (currentTripSteps < 100000) {
diff --git a/src/displayapp/screens/Steps.h b/src/displayapp/screens/Steps.h
index 1a4fe647..4824be6a 100644
--- a/src/displayapp/screens/Steps.h
+++ b/src/displayapp/screens/Steps.h
@@ -32,6 +32,7 @@ namespace Pinetime {
uint32_t currentTripSteps = 0;
lv_obj_t* lSteps;
+ lv_obj_t* lStepsYesterday;
lv_obj_t* stepsArc;
lv_obj_t* resetBtn;
lv_obj_t* resetButtonLabel;