summaryrefslogtreecommitdiff
path: root/src/components/motion
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/motion')
-rw-r--r--src/components/motion/MotionController.cpp11
-rw-r--r--src/components/motion/MotionController.h3
2 files changed, 14 insertions, 0 deletions
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp
index b0dbada4..a2384d79 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;
+}
diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h
index ff715093..c72d8a4a 100644
--- a/src/components/motion/MotionController.h
+++ b/src/components/motion/MotionController.h
@@ -2,6 +2,7 @@
#include <cstdint>
#include <drivers/Bma421.h>
+#include <components/ble/MotionService.h>
namespace Pinetime {
namespace Controllers {
@@ -39,6 +40,7 @@ namespace Pinetime {
}
void Init(Pinetime::Drivers::Bma421::DeviceTypes types);
+ void SetService(Pinetime::Controllers::MotionService* service);
private:
uint32_t nbSteps;
@@ -48,6 +50,7 @@ namespace Pinetime {
int16_t lastYForWakeUp = 0;
bool isSensorOk = false;
DeviceTypes deviceType = DeviceTypes::Unknown;
+ Pinetime::Controllers::MotionService* service = nullptr;
};
}
} \ No newline at end of file