summaryrefslogtreecommitdiff
path: root/src/components/motion/MotionController.cpp
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-03-31 18:30:10 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-03-31 18:30:10 (GMT)
commit1e395850df59ed5406ea8472febeaf602ded5e80 (patch)
tree280a08d8b38e73fbe6950e537de3937ac12f9ba9 /src/components/motion/MotionController.cpp
parent6631fee198720c2710bbf09308b30e74c11814b0 (diff)
.
Diffstat (limited to 'src/components/motion/MotionController.cpp')
-rw-r--r--src/components/motion/MotionController.cpp8
1 files changed, 8 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) {