diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-04-01 22:53:10 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-04-01 22:56:55 (GMT) |
| commit | b9f3e0d8bdb4ed02a9364fe1d025e441dc7c8ded (patch) | |
| tree | 6833dcfffee37a710b4366331084d09e02727ff6 | |
| parent | 2557f8ed6226916d1a82905e7fed3987b3f774f5 (diff) | |
.
| -rw-r--r-- | src/displayapp/DisplayApp.cpp | 2 | ||||
| -rw-r--r-- | src/displayapp/screens/Motion.cpp | 14 | ||||
| -rw-r--r-- | src/displayapp/screens/Motion.h | 4 | ||||
| -rw-r--r-- | src/libs/lv_conf.h | 2 |
4 files changed, 15 insertions, 7 deletions
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index cb381aa..e4c7a6c 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -389,7 +389,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) currentScreen = std::make_unique<Screens::StopWatch>(this, *systemTask); break; case Apps::Motion: - currentScreen = std::make_unique<Screens::Motion>(this, *systemTask, motionController); + currentScreen = std::make_unique<Screens::Motion>(this, *systemTask, motionController, motorController); break; } currentApp = app; diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp index 601fbbf..6a0b543 100644 --- a/src/displayapp/screens/Motion.cpp +++ b/src/displayapp/screens/Motion.cpp @@ -18,8 +18,8 @@ using namespace Pinetime::Applications::Screens; -Motion::Motion(Pinetime::Applications::DisplayApp* app, System::SystemTask& systemTask, Controllers::MotionController& motionController) - : Screen(app), motionController {motionController}, systemTask {systemTask} { +Motion::Motion(Pinetime::Applications::DisplayApp* app, System::SystemTask& systemTask, Controllers::MotionController& motionController, Controllers::MotorController& motorController) + : Screen(app), motionController {motionController}, motorController {motorController}, systemTask {systemTask} { systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping); chart = lv_chart_create(lv_scr_act(), NULL); @@ -122,7 +122,9 @@ void Motion::Refresh() { lv_label_set_text_static(label, labelText); if (jump_started_or_ended) { if (new_record) { - lv_label_set_text_fmt(recordLabel, "%f", ((float)current_jump_length)); + uint32_t a = (current_jump_length*100000.0); + lv_label_set_text_fmt(recordLabel, "%d.%03d", a/1000, a%1000); + motorController.RunForDuration(35); } lv_color_t color; if (jumping) { @@ -130,7 +132,11 @@ void Motion::Refresh() { } else { double best_jump_length = records[0].jump_length; if (current_jump_length * 100 > best_jump_length) { - lv_label_set_text_fmt(lastLabel, "%f", ((float)current_jump_length)); + uint32_t a = (current_jump_length*100000.0); + lv_label_set_text_fmt(recordLabel, "%d.%03d", a/1000, a%1000); + if (!new_record && current_jump_length > 0.05) { + motorController.RunForDuration(11); + } } color = LV_COLOR_ORANGE; } diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h index 2554ffd..421bf4d 100644 --- a/src/displayapp/screens/Motion.h +++ b/src/displayapp/screens/Motion.h @@ -6,6 +6,7 @@ #include "displayapp/screens/Screen.h" #include <lvgl/src/lv_core/lv_style.h> #include <lvgl/src/lv_core/lv_obj.h> +#include <components/motor/MotorController.h> #include <components/motion/MotionController.h> namespace Pinetime { @@ -14,13 +15,14 @@ namespace Pinetime { class Motion : public Screen { public: - Motion(DisplayApp* app, System::SystemTask& systemTask, Controllers::MotionController& motionController); + Motion(DisplayApp* app, System::SystemTask& systemTask, Controllers::MotionController& motionController, Controllers::MotorController& motorController); ~Motion() override; void Refresh() override; private: Controllers::MotionController& motionController; + Controllers::MotorController& motorController; System::SystemTask& systemTask; // bool calibrating = true; bool started = false; diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index 6be43a3..3a20c5b 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -532,7 +532,7 @@ typedef void* lv_font_user_data_t; #define lv_snprintf snprintf #define lv_vsnprintf vsnprintf #else /*!LV_SPRINTF_CUSTOM*/ -#define LV_SPRINTF_DISABLE_FLOAT 0 +#define LV_SPRINTF_DISABLE_FLOAT 1 #endif /*LV_SPRINTF_CUSTOM*/ /*=================== |
