diff options
| author | JF <JF002@users.noreply.github.com> | 2021-10-24 18:06:52 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-24 18:06:52 (GMT) |
| commit | 82ca526ec2db11d9e4aa2d91cd69ed2394e3a843 (patch) | |
| tree | af91df7395abd8bed0d12c276b3703f46cbfadfd /src/components/motion/MotionController.cpp | |
| parent | 9538eb97166410ebc362addfb76ec54895491cd7 (diff) | |
| parent | b3a82288997556b04a64d452ec2067747f1fb706 (diff) | |
Merge pull request #754 from InfiniTimeOrg/add-motion-service
Add motion service
Diffstat (limited to 'src/components/motion/MotionController.cpp')
| -rw-r--r-- | src/components/motion/MotionController.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index b0dbada..a2384d7 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -3,6 +3,14 @@ using namespace Pinetime::Controllers; void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) { + if (this->nbSteps != nbSteps && service != nullptr) { + service->OnNewStepCountValue(nbSteps); + } + + if(service != nullptr && (this->x != x || this->y != y || this->z != z)) { + service->OnNewMotionValues(x, y, z); + } + this->x = x; this->y = y; this->z = z; @@ -41,3 +49,6 @@ void MotionController::Init(Pinetime::Drivers::Bma421::DeviceTypes types) { default: this->deviceType = DeviceTypes::Unknown; break; } } +void MotionController::SetService(Pinetime::Controllers::MotionService* service) { + this->service = service; +} |
