At midnight, "shift" the step counter history

This commit is contained in:
Sándor Rátkai 2024-09-09 00:11:22 +02:00 committed by Hunman
parent 1cce240787
commit 64ec5131b0
3 changed files with 8 additions and 0 deletions

View file

@ -36,6 +36,11 @@ namespace {
}
}
void MotionController::AdvanceDay() {
--nbSteps; // Higher index = further in the past
nbSteps[today] = -1; // Ensure that the `this->nbSteps[today] != nbSteps` condition in `Update()` will be FALSE
}
void MotionController::Update(int16_t x, int16_t y, int16_t z, MotionController::step_t nbSteps) {
if (this->nbSteps[today] != nbSteps && service != nullptr) {
service->OnNewStepCountValue(nbSteps);

View file

@ -27,6 +27,8 @@ namespace Pinetime {
using step_t = uint32_t;
static constexpr size_t stepHistorySize = 2; // Store this many day's step counter
void AdvanceDay();
void Update(int16_t x, int16_t y, int16_t z, step_t nbSteps);
int16_t X() const {

View file

@ -428,6 +428,7 @@ void SystemTask::UpdateMotion() {
if (stepCounterMustBeReset) {
motionSensor.ResetStepCounter();
motionController.AdvanceDay();
stepCounterMustBeReset = false;
}