Added an enum for the index of today and yesterday

This commit is contained in:
Sándor Rátkai 2024-09-09 00:06:19 +02:00 committed by Hunman
parent 9687154f2f
commit 090c3bfe21
2 changed files with 10 additions and 5 deletions

View file

@ -37,7 +37,7 @@ namespace {
}
void MotionController::Update(int16_t x, int16_t y, int16_t z, MotionController::step_t nbSteps) {
if (this->nbSteps[0] != nbSteps && service != nullptr) {
if (this->nbSteps[today] != nbSteps && service != nullptr) {
service->OnNewStepCountValue(nbSteps);
}
@ -57,11 +57,11 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, MotionController:
stats = GetAccelStats();
int32_t deltaSteps = nbSteps - this->nbSteps[0];
int32_t deltaSteps = nbSteps - this->nbSteps[today];
if (deltaSteps > 0) {
currentTripSteps += deltaSteps;
}
this->nbSteps[0] = nbSteps;
this->nbSteps[today] = nbSteps;
}
MotionController::AccelStats MotionController::GetAccelStats() const {

View file

@ -10,7 +10,7 @@
namespace Pinetime {
namespace Controllers {
class MotionService;
class MotionController {
public:
enum class DeviceTypes {
@ -19,6 +19,11 @@ namespace Pinetime {
BMA425,
};
enum Days {
today = 0,
yesterday = 1,
};
using step_t = uint32_t;
static constexpr size_t stepHistorySize = 2; // Store this many day's step counter
@ -37,7 +42,7 @@ namespace Pinetime {
}
step_t NbSteps() const {
return nbSteps[0];
return nbSteps[today];
}
void ResetTrip() {