mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 23:21:53 +02:00
Converted MotionController::nbSteps to CircularBuffer internally
This commit is contained in:
parent
a083358b98
commit
9687154f2f
|
@ -37,7 +37,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MotionController::Update(int16_t x, int16_t y, int16_t z, MotionController::step_t nbSteps) {
|
void MotionController::Update(int16_t x, int16_t y, int16_t z, MotionController::step_t nbSteps) {
|
||||||
if (this->nbSteps != nbSteps && service != nullptr) {
|
if (this->nbSteps[0] != nbSteps && service != nullptr) {
|
||||||
service->OnNewStepCountValue(nbSteps);
|
service->OnNewStepCountValue(nbSteps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,11 +57,11 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, MotionController:
|
||||||
|
|
||||||
stats = GetAccelStats();
|
stats = GetAccelStats();
|
||||||
|
|
||||||
int32_t deltaSteps = nbSteps - this->nbSteps;
|
int32_t deltaSteps = nbSteps - this->nbSteps[0];
|
||||||
if (deltaSteps > 0) {
|
if (deltaSteps > 0) {
|
||||||
currentTripSteps += deltaSteps;
|
currentTripSteps += deltaSteps;
|
||||||
}
|
}
|
||||||
this->nbSteps = nbSteps;
|
this->nbSteps[0] = nbSteps;
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionController::AccelStats MotionController::GetAccelStats() const {
|
MotionController::AccelStats MotionController::GetAccelStats() const {
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace Pinetime {
|
||||||
};
|
};
|
||||||
|
|
||||||
using step_t = uint32_t;
|
using step_t = uint32_t;
|
||||||
|
static constexpr size_t stepHistorySize = 2; // Store this many day's step counter
|
||||||
|
|
||||||
void Update(int16_t x, int16_t y, int16_t z, step_t nbSteps);
|
void Update(int16_t x, int16_t y, int16_t z, step_t nbSteps);
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ namespace Pinetime {
|
||||||
}
|
}
|
||||||
|
|
||||||
step_t NbSteps() const {
|
step_t NbSteps() const {
|
||||||
return nbSteps;
|
return nbSteps[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetTrip() {
|
void ResetTrip() {
|
||||||
|
@ -70,7 +71,7 @@ namespace Pinetime {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
step_t nbSteps = 0;
|
Utility::CircularBuffer<step_t, stepHistorySize> nbSteps = {0};
|
||||||
step_t currentTripSteps = 0;
|
step_t currentTripSteps = 0;
|
||||||
|
|
||||||
TickType_t lastTime = 0;
|
TickType_t lastTime = 0;
|
||||||
|
|
Loading…
Reference in a new issue