summaryrefslogtreecommitdiff
path: root/src/components/motion
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/motion')
-rw-r--r--src/components/motion/MotionController.cpp4
-rw-r--r--src/components/motion/MotionController.h10
2 files changed, 10 insertions, 4 deletions
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp
index cae49105..59114f4c 100644
--- a/src/components/motion/MotionController.cpp
+++ b/src/components/motion/MotionController.cpp
@@ -14,7 +14,11 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps)
this->x = x;
this->y = y;
this->z = z;
+ deltaSteps = nbSteps - this->nbSteps;
this->nbSteps = nbSteps;
+ if(deltaSteps > 0){
+ currentTripSteps += deltaSteps;
+ }
}
bool MotionController::ShouldWakeUp(bool isSleeping) {
diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h
index aea82f76..17bdc52e 100644
--- a/src/components/motion/MotionController.h
+++ b/src/components/motion/MotionController.h
@@ -28,11 +28,12 @@ namespace Pinetime {
uint32_t NbSteps() const {
return nbSteps;
}
- void SetTripSteps(uint32_t steps) {
- stepsAtLastTrip = steps;
+
+ void ResetTrip() {
+ currentTripSteps = 0;
}
uint32_t GetTripSteps() const {
- return stepsAtLastTrip;
+ return currentTripSteps;
}
bool ShouldWakeUp(bool isSleeping);
@@ -50,7 +51,8 @@ namespace Pinetime {
private:
uint32_t nbSteps;
- uint32_t stepsAtLastTrip = 0;
+ int32_t deltaSteps = 0;
+ uint32_t currentTripSteps = 0;
int16_t x;
int16_t y;
int16_t z;