mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 23:21:53 +02:00
Changed MotionController::Days from enum to enum class
This commit is contained in:
parent
a2c7e96839
commit
66e29db565
|
@ -37,14 +37,15 @@ namespace {
|
|||
|
||||
void MotionController::AdvanceDay() {
|
||||
--nbSteps; // Higher index = further in the past
|
||||
nbSteps[Today] = 0;
|
||||
NbStepsRef(Days::Today) = 0;
|
||||
if (service != nullptr) {
|
||||
service->OnNewStepCountValue(nbSteps[Today]);
|
||||
service->OnNewStepCountValue(NbSteps(Days::Today));
|
||||
}
|
||||
}
|
||||
|
||||
void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) {
|
||||
if (this->nbSteps[Today] != nbSteps && service != nullptr) {
|
||||
uint32_t& oldSteps = NbStepsRef(Days::Today);
|
||||
if (oldSteps != nbSteps && service != nullptr) {
|
||||
service->OnNewStepCountValue(nbSteps);
|
||||
}
|
||||
|
||||
|
@ -64,11 +65,11 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps)
|
|||
|
||||
stats = GetAccelStats();
|
||||
|
||||
int32_t deltaSteps = nbSteps - this->nbSteps[Today];
|
||||
int32_t deltaSteps = nbSteps - oldSteps;
|
||||
if (deltaSteps > 0) {
|
||||
currentTripSteps += deltaSteps;
|
||||
}
|
||||
this->nbSteps[Today] = nbSteps;
|
||||
oldSteps = nbSteps;
|
||||
}
|
||||
|
||||
MotionController::AccelStats MotionController::GetAccelStats() const {
|
||||
|
|
|
@ -18,12 +18,13 @@ namespace Pinetime {
|
|||
BMA425,
|
||||
};
|
||||
|
||||
enum Days {
|
||||
enum class Days : uint8_t {
|
||||
Today = 0,
|
||||
Yesterday = 1,
|
||||
Yesterday,
|
||||
Last,
|
||||
};
|
||||
|
||||
static constexpr size_t stepHistorySize = 2; // Store this many day's step counter
|
||||
static constexpr size_t stepHistorySize = static_cast<std::underlying_type_t<Days>>(Days::Last); // Store this many day's step counter
|
||||
|
||||
void AdvanceDay();
|
||||
|
||||
|
@ -41,8 +42,8 @@ namespace Pinetime {
|
|||
return zHistory[0];
|
||||
}
|
||||
|
||||
uint32_t NbSteps(Days day = Today) const {
|
||||
return nbSteps[day];
|
||||
uint32_t NbSteps(Days day = Days::Today) const {
|
||||
return nbSteps[static_cast<std::underlying_type_t<Days>>(day)];
|
||||
}
|
||||
|
||||
void ResetTrip() {
|
||||
|
@ -79,6 +80,10 @@ namespace Pinetime {
|
|||
Utility::CircularBuffer<uint32_t, stepHistorySize> nbSteps = {0};
|
||||
uint32_t currentTripSteps = 0;
|
||||
|
||||
uint32_t& NbStepsRef(Days day = Days::Today) {
|
||||
return nbSteps[static_cast<std::underlying_type_t<Days>>(day)];
|
||||
}
|
||||
|
||||
TickType_t lastTime = 0;
|
||||
TickType_t time = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue