summaryrefslogtreecommitdiff
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
parent6631fee198720c2710bbf09308b30e74c11814b0 (diff)
.
-rw-r--r--src/components/motion/MotionController.cpp8
-rw-r--r--src/components/motion/MotionController.h2
-rw-r--r--src/displayapp/screens/Motion.cpp4
3 files changed, 12 insertions, 2 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 {
diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp
index fe630d9..97e01af 100644
--- a/src/displayapp/screens/Motion.cpp
+++ b/src/displayapp/screens/Motion.cpp
@@ -15,7 +15,7 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
lv_chart_set_range(chart, -1100, 1100);
lv_chart_set_update_mode(chart, LV_CHART_UPDATE_MODE_SHIFT);
- lv_chart_set_point_count(chart, 10);
+ lv_chart_set_point_count(chart, 6);
/*Add 3 data series*/
ser1 = lv_chart_add_series(chart, LV_COLOR_RED);
@@ -42,7 +42,7 @@ Motion::~Motion() {
}
void Motion::Refresh() {
- lv_chart_set_next(chart, ser1, motionController.X());
+ lv_chart_set_next(chart, ser1, motionController.G());
// lv_chart_set_next(chart, ser2, motionController.Y());
// lv_chart_set_next(chart, ser3, motionController.Z());
#if 0