mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 15:11:51 +02:00
At midnight, "shift" the step counter history
This commit is contained in:
parent
1cce240787
commit
64ec5131b0
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -428,6 +428,7 @@ void SystemTask::UpdateMotion() {
|
|||
|
||||
if (stepCounterMustBeReset) {
|
||||
motionSensor.ResetStepCounter();
|
||||
motionController.AdvanceDay();
|
||||
stepCounterMustBeReset = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue