summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-03-31 19:05:36 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-03-31 19:05:36 (GMT)
commitc7f80dc5b3ccb2db08355b993a7855a5655e7d6b (patch)
tree870a7d7573fafbf48558379d58da3cf9faaf7c8a
parentee48e3f35b732eeddc9496da396aa33a31ebee2d (diff)
More testing of G sensor
-rw-r--r--src/components/motion/MotionController.cpp9
-rw-r--r--src/displayapp/screens/Motion.cpp10
-rw-r--r--src/displayapp/screens/Motion.h1
3 files changed, 15 insertions, 5 deletions
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp
index a7c5ecc..6a3a84d 100644
--- a/src/components/motion/MotionController.cpp
+++ b/src/components/motion/MotionController.cpp
@@ -9,11 +9,12 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z) {
this->z = z;
}
-int16_t MotionController::G() {
+uint16_t MotionController::G() {
float X = x; X *= X;
- float Y = y; Y *= Y;
- float Z = z; Z *= Z;
- return (int16_t) std::sqrt(X + Y + Z);
+ float Y = y; X += Y * Y;
+ Y = z; X += Y * Y;
+ X = std::sqrt(X);
+ if (X > 0xffff) { return 0xffff; } else { return X; }
}
bool MotionController::Should_RaiseWake(bool isSleeping) {
diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp
index 97e01af..00c3172 100644
--- a/src/displayapp/screens/Motion.cpp
+++ b/src/displayapp/screens/Motion.cpp
@@ -27,7 +27,8 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
// lv_chart_init_points(chart, ser3, 0);
lv_chart_refresh(chart); /*Required after direct set*/
- // label = lv_label_create(lv_scr_act(), NULL);
+ label = lv_label_create(lv_scr_act(), NULL);
+ lv_label_set_text_static(label, labelText);
// lv_label_set_text_fmt(label, "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#", 0, 0, 0);
// lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
// lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
@@ -42,9 +43,16 @@ Motion::~Motion() {
}
void Motion::Refresh() {
+ uint16_t G = motionController.G()
lv_chart_set_next(chart, ser1, motionController.G());
// lv_chart_set_next(chart, ser2, motionController.Y());
// lv_chart_set_next(chart, ser3, motionController.Z());
+ labelText[4] = '0'+(G%10); G /= 10;
+ labelText[3] = '0'+(G%10); G /= 10;
+ labelText[2] = '0'+(G%10); G /= 10;
+ labelText[1] = '0'+(G%10); G /= 10;
+ labelText[0] = '0'+G; G /= 10;
+ lv_label_set_text_static(label, labelText);
#if 0
lv_label_set_text_fmt(label,
"X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#",
diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h
index 4d2bd4f..2341f24 100644
--- a/src/displayapp/screens/Motion.h
+++ b/src/displayapp/screens/Motion.h
@@ -20,6 +20,7 @@ namespace Pinetime {
private:
Controllers::MotionController& motionController;
+ char labelText = { '0', '0', '0', '0', '0', 0 };
lv_obj_t* chart;
lv_chart_series_t* ser1;
lv_chart_series_t* ser2;