summaryrefslogtreecommitdiff
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
parent92ce5ee9751f01dc63330ad25910c674420cd984 (diff)
Add back motion app
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/displayapp/Apps.h1
-rw-r--r--src/displayapp/DisplayApp.cpp4
-rw-r--r--src/displayapp/screens/ApplicationList.cpp13
-rw-r--r--src/displayapp/screens/Motion.cpp55
-rw-r--r--src/displayapp/screens/Motion.h34
6 files changed, 109 insertions, 1 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 85db7fd..2e2b6d2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -394,10 +394,12 @@ list(APPEND SOURCE_FILES
displayapp/screens/Brightness.cpp
displayapp/screens/Label.cpp
displayapp/screens/FirmwareUpdate.cpp
+ displayapp/screens/Motion.cpp
displayapp/screens/FirmwareValidation.cpp
displayapp/screens/ApplicationList.cpp
displayapp/screens/Notifications.cpp
displayapp/screens/FlashLight.cpp
+ displayapp/screens/Motion.cpp
displayapp/screens/List.cpp
displayapp/screens/Timer.cpp
displayapp/screens/Error.cpp
@@ -567,6 +569,7 @@ set(INCLUDE_FILES
displayapp/Apps.h
displayapp/screens/Notifications.h
displayapp/screens/Timer.h
+ displayapp/screens/Motion.h
displayapp/screens/Alarm.h
displayapp/Colors.h
drivers/St7789.h
diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h
index b97080c..85d5f25 100644
--- a/src/displayapp/Apps.h
+++ b/src/displayapp/Apps.h
@@ -14,6 +14,7 @@ namespace Pinetime {
Timer,
StopWatch,
FlashLight,
+ Motion,
QuickSettings,
Settings,
SettingTimeFormat,
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index 30b86ed..223b150 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -1,6 +1,7 @@
#include "displayapp/DisplayApp.h"
#include <libraries/log/nrf_log.h>
#include "displayapp/screens/Timer.h"
+#include "displayapp/screens/Motion.h"
#include "displayapp/screens/Alarm.h"
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
@@ -387,6 +388,9 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
case Apps::StopWatch:
currentScreen = std::make_unique<Screens::StopWatch>(this, *systemTask);
break;
+ case Apps::Motion:
+ currentScreen = std::make_unique<Screens::Motion>(this, motionController);
+ break;
}
currentApp = app;
}
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;
+ };
+ }
+ }
+}