summaryrefslogtreecommitdiff
path: root/src/components/motion/MotionController.h
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-04-01 21:04:48 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-04-01 21:04:48 (GMT)
commit79fc7313648ac07885f17e51260f44e858410d22 (patch)
tree34cce96f7da7d119516540ef38b69844589f276d /src/components/motion/MotionController.h
parentc7f80dc5b3ccb2db08355b993a7855a5655e7d6b (diff)
Game complete hopefully
Diffstat (limited to 'src/components/motion/MotionController.h')
-rw-r--r--src/components/motion/MotionController.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h
index 21bfbdb..06429c8 100644
--- a/src/components/motion/MotionController.h
+++ b/src/components/motion/MotionController.h
@@ -1,5 +1,6 @@
#pragma once
+#include <cmath>
#include <cstdint>
#include <drivers/Bma421.h>
@@ -25,8 +26,6 @@ namespace Pinetime {
return z;
}
- int16_t G();
-
bool Should_RaiseWake(bool isSleeping);
void IsSensorOk(bool isOk);
bool IsSensorOk() const {
@@ -39,6 +38,30 @@ namespace Pinetime {
void Init(Pinetime::Drivers::Bma421::DeviceTypes types);
+ inline double GXYZ(double &X, double &Y, double &Z) const {
+ X = x; Y = y; Z = z;
+ return std::sqrt(X*X + Y*Y + Z*Z);
+ }
+
+ inline double G() const {
+ double X = x; X *= X;
+ double Y = y; X += Y * Y;
+ Y = z; X += Y * Y;
+ return std::sqrt(X) * 0.;
+ }
+
+ inline auto G_v0() const {
+ float X = x; X *= X;
+ float Y = y; X += Y * Y;
+ Y = z; X += Y * Y;
+ return std::sqrt(X);
+ }
+
+ inline uint16_t G_uint16() const {
+ auto X = G_v0();
+ if (X > 0xffff) { return 0xffff; } else { return X; }
+ }
+
private:
int16_t x;
int16_t y;