summaryrefslogtreecommitdiff
path: root/src/components/motion
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/motion')
-rw-r--r--src/components/motion/MotionController.cpp8
-rw-r--r--src/components/motion/MotionController.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp
index 0404e3f..12c3514 100644
--- a/src/components/motion/MotionController.cpp
+++ b/src/components/motion/MotionController.cpp
@@ -1,3 +1,4 @@
+#include <cmath>
#include "components/motion/MotionController.h"
#include "os/os_cputime.h"
using namespace Pinetime::Controllers;
@@ -8,6 +9,13 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z) {
this->z = z;
}
+int16_t MotionController::G() {
+ float X = x; X *= X;
+ float Y = y; Y *= Y;
+ float Z = z; Z *= Z;
+ return (int16_t) std::sqrtf(X + Y + Z);
+}
+
bool MotionController::Should_RaiseWake(bool isSleeping) {
if ((x + 335) <= 670 && z < 0) {
if (not isSleeping) {
diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h
index a56991a..21bfbdb 100644
--- a/src/components/motion/MotionController.h
+++ b/src/components/motion/MotionController.h
@@ -25,6 +25,8 @@ namespace Pinetime {
return z;
}
+ int16_t G();
+
bool Should_RaiseWake(bool isSleeping);
void IsSensorOk(bool isOk);
bool IsSensorOk() const {