summaryrefslogtreecommitdiff
path: root/src/displayapp/screens
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-03-31 14:04:15 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-03-31 14:05:14 (GMT)
commitef816addbc85b4447d9f304d218d8430aef473fd (patch)
tree48eab529009bbfaad6a30fc9bd22e84f97713201 /src/displayapp/screens
parent92ce5ee9751f01dc63330ad25910c674420cd984 (diff)
Add back motion app
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/ApplicationList.cpp13
-rw-r--r--src/displayapp/screens/Motion.cpp55
-rw-r--r--src/displayapp/screens/Motion.h34
3 files changed, 101 insertions, 1 deletions
diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp
index d49d493..98b6368 100644
--- a/src/displayapp/screens/ApplicationList.cpp
+++ b/src/displayapp/screens/ApplicationList.cpp
@@ -38,9 +38,20 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen1() {
std::array<Screens::Tile::Applications, 6> applications {{
{Symbols::stopWatch, Apps::StopWatch},
{Symbols::hourGlass, Apps::Timer},
+ {Symbols::chartLine, Apps::Motion},
{Symbols::clock, Apps::Alarm},
}};
- return std::make_unique<Screens::Tile>(0, 1, app, settingsController, batteryController, dateTimeController, applications);
+ return std::make_unique<Screens::Tile>(1, 2, app, settingsController, batteryController, dateTimeController, applications);
}
+/*std::unique_ptr<Screen> ApplicationList::CreateScreen3() {
+ std::array<Screens::Tile::Applications, 6> applications {
+ {{"A", Apps::Meter},
+ {"C", Apps::Clock},
+ {"F", Apps::Brightness}
+ }
+ };
+
+ return std::make_unique<Screens::Tile>(2, 3, app, settingsController, batteryController, dateTimeController, applications);
+}*/
diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp
new file mode 100644
index 0000000..1bc7bd4
--- /dev/null
+++ b/src/displayapp/screens/Motion.cpp
@@ -0,0 +1,55 @@
+#include "displayapp/screens/Motion.h"
+#include <lvgl/lvgl.h>
+#include "displayapp/DisplayApp.h"
+
+using namespace Pinetime::Applications::Screens;
+
+Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionController& motionController)
+ : Screen(app), motionController {motionController} {
+ chart = lv_chart_create(lv_scr_act(), NULL);
+ lv_obj_set_size(chart, 240, 240);
+ lv_obj_align(chart, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
+ lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Show lines and points too*/
+ // lv_chart_set_series_opa(chart, LV_OPA_70); /*Opacity of the data series*/
+ // lv_chart_set_series_width(chart, 4); /*Line width and point radious*/
+
+ 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);
+
+ /*Add 3 data series*/
+ ser1 = lv_chart_add_series(chart, LV_COLOR_RED);
+ ser2 = lv_chart_add_series(chart, LV_COLOR_GREEN);
+ ser3 = lv_chart_add_series(chart, LV_COLOR_YELLOW);
+
+ lv_chart_init_points(chart, ser1, 0);
+ lv_chart_init_points(chart, ser2, 0);
+ lv_chart_init_points(chart, ser3, 0);
+ lv_chart_refresh(chart); /*Required after direct set*/
+
+ label = lv_label_create(lv_scr_act(), NULL);
+ 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);
+ lv_label_set_recolor(label, true);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
+}
+
+Motion::~Motion() {
+ lv_task_del(taskRefresh);
+ lv_obj_clean(lv_scr_act());
+}
+
+void Motion::Refresh() {
+ lv_chart_set_next(chart, ser1, motionController.X());
+ lv_chart_set_next(chart, ser2, motionController.Y());
+ lv_chart_set_next(chart, ser3, motionController.Z());
+
+ lv_label_set_text_fmt(label,
+ "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#",
+ motionController.X() / 0x10,
+ motionController.Y() / 0x10,
+ motionController.Z() / 0x10);
+ lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
+}
diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h
new file mode 100644
index 0000000..4d2bd4f
--- /dev/null
+++ b/src/displayapp/screens/Motion.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <cstdint>
+#include <chrono>
+#include "displayapp/screens/Screen.h"
+#include <lvgl/src/lv_core/lv_style.h>
+#include <lvgl/src/lv_core/lv_obj.h>
+#include <components/motion/MotionController.h>
+
+namespace Pinetime {
+ namespace Applications {
+ namespace Screens {
+
+ class Motion : public Screen {
+ public:
+ Motion(DisplayApp* app, Controllers::MotionController& motionController);
+ ~Motion() override;
+
+ void Refresh() override;
+
+ private:
+ Controllers::MotionController& motionController;
+ lv_obj_t* chart;
+ lv_chart_series_t* ser1;
+ lv_chart_series_t* ser2;
+ lv_chart_series_t* ser3;
+ lv_obj_t* label;
+
+ lv_obj_t* labelStep;
+ lv_task_t* taskRefresh;
+ };
+ }
+ }
+}