From 5e1f4839daff075d6411f41148eb6d5d0543bcee Mon Sep 17 00:00:00 2001 From: Clemens von Molo Date: Sun, 31 Oct 2021 21:23:43 +0100 Subject: InfiniPaint vibrate on colorchange, fix color rotation diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index abe5851..04aec4c 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -410,7 +410,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) currentScreen = std::make_unique(this); break; case Apps::Paint: - currentScreen = std::make_unique(this, lvgl); + currentScreen = std::make_unique(this, lvgl,motorController); break; case Apps::Paddle: currentScreen = std::make_unique(this, lvgl); diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp index 85a5e82..66391b1 100644 --- a/src/displayapp/screens/InfiniPaint.cpp +++ b/src/displayapp/screens/InfiniPaint.cpp @@ -4,7 +4,7 @@ using namespace Pinetime::Applications::Screens; -InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} { +InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl, Pinetime::Controllers::MotorController& motor) : Screen(app), lvgl {lvgl}, motor{motor} { std::fill(b, b + bufferSize, selectColor); } @@ -16,9 +16,6 @@ bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) { switch (event) { case Pinetime::Applications::TouchEvents::LongTap: switch (color) { - case 0: - selectColor = LV_COLOR_MAGENTA; - break; case 1: selectColor = LV_COLOR_GREEN; break; @@ -43,11 +40,13 @@ bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) { default: color = 0; + selectColor = LV_COLOR_MAGENTA; break; } std::fill(b, b + bufferSize, selectColor); color++; + motor.RunForDuration(50); return true; default: return true; diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h index 0a70e03..8a96fc6 100644 --- a/src/displayapp/screens/InfiniPaint.h +++ b/src/displayapp/screens/InfiniPaint.h @@ -3,6 +3,7 @@ #include #include #include "Screen.h" +#include "components/motor/MotorController.h" namespace Pinetime { namespace Components { @@ -13,7 +14,7 @@ namespace Pinetime { class InfiniPaint : public Screen { public: - InfiniPaint(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl); + InfiniPaint(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl, Controllers::MotorController& motor); ~InfiniPaint() override; @@ -23,12 +24,13 @@ namespace Pinetime { private: Pinetime::Components::LittleVgl& lvgl; + Controllers::MotorController& motor; static constexpr uint16_t width = 10; static constexpr uint16_t height = 10; static constexpr uint16_t bufferSize = width * height; lv_color_t b[bufferSize]; lv_color_t selectColor = LV_COLOR_WHITE; - uint8_t color = 2; + uint8_t color = 3; }; } } -- cgit v0.10.2 From 2d985309760172db00b0b9cb7bd523579413d634 Mon Sep 17 00:00:00 2001 From: Clemens von Molo Date: Mon, 1 Nov 2021 11:46:27 +0100 Subject: color rotation using modulo, ran clang-format for InfiniPaint diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 04aec4c..a90a1e5 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -410,7 +410,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) currentScreen = std::make_unique(this); break; case Apps::Paint: - currentScreen = std::make_unique(this, lvgl,motorController); + currentScreen = std::make_unique(this, lvgl, motorController); break; case Apps::Paddle: currentScreen = std::make_unique(this, lvgl); diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp index 66391b1..c5ff27b 100644 --- a/src/displayapp/screens/InfiniPaint.cpp +++ b/src/displayapp/screens/InfiniPaint.cpp @@ -4,7 +4,10 @@ using namespace Pinetime::Applications::Screens; -InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl, Pinetime::Controllers::MotorController& motor) : Screen(app), lvgl {lvgl}, motor{motor} { +InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, + Pinetime::Components::LittleVgl& lvgl, + Pinetime::Controllers::MotorController& motor) + : Screen(app), lvgl {lvgl}, motor {motor} { std::fill(b, b + bufferSize, selectColor); } @@ -15,7 +18,11 @@ InfiniPaint::~InfiniPaint() { bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) { switch (event) { case Pinetime::Applications::TouchEvents::LongTap: + color = (color + 1) % 8; switch (color) { + case 0: + selectColor = LV_COLOR_MAGENTA; + break; case 1: selectColor = LV_COLOR_GREEN; break; @@ -40,12 +47,10 @@ bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) { default: color = 0; - selectColor = LV_COLOR_MAGENTA; break; } std::fill(b, b + bufferSize, selectColor); - color++; motor.RunForDuration(50); return true; default: diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h index 8a96fc6..fb0bd9b 100644 --- a/src/displayapp/screens/InfiniPaint.h +++ b/src/displayapp/screens/InfiniPaint.h @@ -1,9 +1,9 @@ #pragma once -#include -#include #include "Screen.h" #include "components/motor/MotorController.h" +#include +#include namespace Pinetime { namespace Components { @@ -30,7 +30,7 @@ namespace Pinetime { static constexpr uint16_t bufferSize = width * height; lv_color_t b[bufferSize]; lv_color_t selectColor = LV_COLOR_WHITE; - uint8_t color = 3; + uint8_t color = 2; }; } } -- cgit v0.10.2 From 75f0bbb7ca51fa0aa65c8c3d4081a5e8d8d48c55 Mon Sep 17 00:00:00 2001 From: Clemens von Molo Date: Mon, 1 Nov 2021 12:10:06 +0100 Subject: change paint vibration to 35ms diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp index c5ff27b..271a022 100644 --- a/src/displayapp/screens/InfiniPaint.cpp +++ b/src/displayapp/screens/InfiniPaint.cpp @@ -51,7 +51,7 @@ bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } std::fill(b, b + bufferSize, selectColor); - motor.RunForDuration(50); + motor.RunForDuration(35); return true; default: return true; -- cgit v0.10.2