diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 77fce63d..f7520708 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -475,7 +475,7 @@ list(APPEND SOURCE_FILES components/timer/TimerController.cpp components/alarm/AlarmController.cpp components/fs/FS.cpp - drivers/Cst816s.cpp + drivers/touchpanels/Cst816s.cpp FreeRTOS/port.c FreeRTOS/port_cmsis_systick.c FreeRTOS/port_cmsis.c @@ -540,7 +540,7 @@ list(APPEND RECOVERY_SOURCE_FILES components/settings/Settings.cpp components/timer/TimerController.cpp components/alarm/AlarmController.cpp - drivers/Cst816s.cpp + drivers/touchpanels/Cst816s.cpp FreeRTOS/port.c FreeRTOS/port_cmsis_systick.c FreeRTOS/port_cmsis.c @@ -659,7 +659,7 @@ set(INCLUDE_FILES components/settings/Settings.h components/timer/TimerController.h components/alarm/AlarmController.h - drivers/Cst816s.h + drivers/touchpanels/Cst816s.h FreeRTOS/portmacro.h FreeRTOS/portmacro_cmsis.h libs/date/include/date/tz.h diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 108e380d..68ea3923 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -30,7 +30,6 @@ #include "displayapp/screens/PassKey.h" #include "displayapp/screens/Error.h" -#include "drivers/Cst816s.h" #include "drivers/St7789.h" #include "drivers/Watchdog.h" #include "systemtask/SystemTask.h" @@ -62,7 +61,7 @@ namespace { DisplayApp::DisplayApp(Drivers::St7789& lcd, Components::LittleVgl& lvgl, - Drivers::Cst816S& touchPanel, + Pinetime::Drivers::TouchPanel& touchPanel, Controllers::Battery& batteryController, Controllers::Ble& bleController, Controllers::DateTime& dateTimeController, diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 4c54e227..972b490c 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -24,7 +24,6 @@ namespace Pinetime { namespace Drivers { class St7789; - class Cst816S; class WatchdogView; } namespace Controllers { @@ -49,7 +48,7 @@ namespace Pinetime { DisplayApp(Drivers::St7789& lcd, Components::LittleVgl& lvgl, - Drivers::Cst816S&, + Pinetime::Drivers::TouchPanel&, Controllers::Battery& batteryController, Controllers::Ble& bleController, Controllers::DateTime& dateTimeController, @@ -76,7 +75,7 @@ namespace Pinetime { private: Pinetime::Drivers::St7789& lcd; Pinetime::Components::LittleVgl& lvgl; - Pinetime::Drivers::Cst816S& touchPanel; + Pinetime::Drivers::TouchPanel& touchPanel; Pinetime::Controllers::Battery& batteryController; Pinetime::Controllers::Ble& bleController; Pinetime::Controllers::DateTime& dateTimeController; diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp index e553aa87..cf1f416f 100644 --- a/src/displayapp/DisplayAppRecovery.cpp +++ b/src/displayapp/DisplayAppRecovery.cpp @@ -12,7 +12,7 @@ using namespace Pinetime::Applications; DisplayApp::DisplayApp(Drivers::St7789& lcd, Components::LittleVgl& lvgl, - Drivers::Cst816S& touchPanel, + Drivers::TouchPanel& touchPanel, Controllers::Battery& batteryController, Controllers::Ble& bleController, Controllers::DateTime& dateTimeController, diff --git a/src/displayapp/DisplayAppRecovery.h b/src/displayapp/DisplayAppRecovery.h index 7d4f0fd0..00f6d19a 100644 --- a/src/displayapp/DisplayAppRecovery.h +++ b/src/displayapp/DisplayAppRecovery.h @@ -6,7 +6,6 @@ #include #include #include "components/gfx/Gfx.h" -#include "drivers/Cst816s.h" #include #include #include @@ -15,11 +14,11 @@ #include "displayapp/Apps.h" #include "displayapp/Messages.h" #include "displayapp/DummyLittleVgl.h" +#include "port/TouchPanel.h" namespace Pinetime { namespace Drivers { class St7789; - class Cst816S; class WatchdogView; } namespace Controllers { @@ -47,7 +46,7 @@ namespace Pinetime { public: DisplayApp(Drivers::St7789& lcd, Components::LittleVgl& lvgl, - Drivers::Cst816S&, + Drivers::TouchPanel&, Controllers::Battery& batteryController, Controllers::Ble& bleController, Controllers::DateTime& dateTimeController, diff --git a/src/displayapp/DummyLittleVgl.h b/src/displayapp/DummyLittleVgl.h index 05355a97..7ca2de83 100644 --- a/src/displayapp/DummyLittleVgl.h +++ b/src/displayapp/DummyLittleVgl.h @@ -4,14 +4,14 @@ #include #include #include -#include +#include "port/TouchPanel.h" namespace Pinetime { namespace Components { class LittleVgl { public: enum class FullRefreshDirections { None, Up, Down }; - LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel) { + LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::TouchPanel & touchPanel) { } LittleVgl(const LittleVgl&) = delete; diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index d5f31848..143defcf 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -4,7 +4,6 @@ #include #include //#include -#include "drivers/Cst816s.h" #include "drivers/St7789.h" using namespace Pinetime::Components; @@ -31,7 +30,7 @@ bool touchpad_read(lv_indev_drv_t* indev_drv, lv_indev_data_t* data) { return lvgl->GetTouchPadInfo(data); } -LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel) : lcd {lcd}, touchPanel {touchPanel} { +LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::TouchPanel& touchPanel) : lcd {lcd}, touchPanel {touchPanel} { } void LittleVgl::Init() { diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index 45826165..09c709d3 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -1,10 +1,10 @@ #pragma once #include +#include "port/TouchPanel.h" namespace Pinetime { namespace Drivers { - class Cst816S; class St7789; } @@ -12,7 +12,7 @@ namespace Pinetime { class LittleVgl { public: enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim }; - LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel); + LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::TouchPanel& touchPanel); LittleVgl(const LittleVgl&) = delete; LittleVgl& operator=(const LittleVgl&) = delete; @@ -40,7 +40,7 @@ namespace Pinetime { void InitTheme(); Pinetime::Drivers::St7789& lcd; - Pinetime::Drivers::Cst816S& touchPanel; + Pinetime::Drivers::TouchPanel& touchPanel; lv_disp_buf_t disp_buf_2; lv_color_t buf2_1[LV_HOR_RES_MAX * 4]; diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index 01c35195..56d1de3e 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -37,7 +37,7 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Ble& bleController, Pinetime::Drivers::WatchdogView& watchdog, Pinetime::Controllers::MotionController& motionController, - Pinetime::Drivers::Cst816S& touchPanel) + Pinetime::Drivers::TouchPanel& touchPanel) : Screen(app), dateTimeController {dateTimeController}, batteryController {batteryController}, diff --git a/src/displayapp/screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h index a382ed8f..9efaea3f 100644 --- a/src/displayapp/screens/SystemInfo.h +++ b/src/displayapp/screens/SystemInfo.h @@ -29,7 +29,7 @@ namespace Pinetime { Pinetime::Controllers::Ble& bleController, Pinetime::Drivers::WatchdogView& watchdog, Pinetime::Controllers::MotionController& motionController, - Pinetime::Drivers::Cst816S& touchPanel); + Pinetime::Drivers::TouchPanel& touchPanel); ~SystemInfo() override; bool OnTouchEvent(TouchEvents event) override; @@ -40,7 +40,7 @@ namespace Pinetime { Pinetime::Controllers::Ble& bleController; Pinetime::Drivers::WatchdogView& watchdog; Pinetime::Controllers::MotionController& motionController; - Pinetime::Drivers::Cst816S& touchPanel; + Pinetime::Drivers::TouchPanel& touchPanel; ScreenList<5> screens; diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h deleted file mode 100644 index 30618691..00000000 --- a/src/drivers/Cst816s.h +++ /dev/null @@ -1,76 +0,0 @@ -#pragma once - -#include "port/infinitime.h" - -namespace Pinetime { - namespace Drivers { - class Cst816S { - public: - enum class Gestures : uint8_t { - None = 0x00, - SlideDown = 0x01, - SlideUp = 0x02, - SlideLeft = 0x03, - SlideRight = 0x04, - SingleTap = 0x05, - DoubleTap = 0x0B, - LongPress = 0x0C - }; - struct TouchInfos { - uint16_t x = 0; - uint16_t y = 0; - Gestures gesture = Gestures::None; - bool touching = false; - bool isValid = false; - }; - - Cst816S(TwiMaster& twiMaster, uint8_t twiAddress); - Cst816S(const Cst816S&) = delete; - Cst816S& operator=(const Cst816S&) = delete; - Cst816S(Cst816S&&) = delete; - Cst816S& operator=(Cst816S&&) = delete; - - bool Init(); - TouchInfos GetTouchInfo(); - void Sleep(); - void Wakeup(); - - uint8_t GetChipId() const { - return chipId; - } - uint8_t GetVendorId() const { - return vendorId; - } - uint8_t GetFwVersion() const { - return fwVersion; - } - - private: - bool CheckDeviceIds(); - - // Unused/Unavailable commented out - static constexpr uint8_t gestureIndex = 1; - static constexpr uint8_t touchPointNumIndex = 2; - // static constexpr uint8_t touchEventIndex = 3; - static constexpr uint8_t touchXHighIndex = 3; - static constexpr uint8_t touchXLowIndex = 4; - // static constexpr uint8_t touchIdIndex = 5; - static constexpr uint8_t touchYHighIndex = 5; - static constexpr uint8_t touchYLowIndex = 6; - // static constexpr uint8_t touchStep = 6; - // static constexpr uint8_t touchXYIndex = 7; - // static constexpr uint8_t touchMiscIndex = 8; - - static constexpr uint8_t maxX = 240; - static constexpr uint8_t maxY = 240; - - TwiMaster& twiMaster; - uint8_t twiAddress; - - uint8_t chipId; - uint8_t vendorId; - uint8_t fwVersion; - }; - - } -} diff --git a/src/drivers/TouchPanel.h b/src/drivers/TouchPanel.h new file mode 100644 index 00000000..5a6b9ffc --- /dev/null +++ b/src/drivers/TouchPanel.h @@ -0,0 +1,83 @@ +#pragma once +#include +#include +#include + +namespace Pinetime { + namespace Drivers { + template + concept IsTouchPanel = requires(touchpanelImpl touchpanel) { + { touchpanel.Init() }; + { touchpanel.GetTouchInfo() }; + { touchpanel.Sleep() }; + { touchpanel.Wakeup() }; + { touchpanel.GetChipId() }; + { touchpanel.GetVendorId() }; + { touchpanel.GetFwVersion() }; + }; + + namespace TouchPanels { + enum class Gestures : uint8_t { + None = 0x00, + SlideDown = 0x01, + SlideUp = 0x02, + SlideLeft = 0x03, + SlideRight = 0x04, + SingleTap = 0x05, + DoubleTap = 0x0B, + LongPress = 0x0C + }; + struct TouchInfos { + uint16_t x = 0; + uint16_t y = 0; + Gestures gesture = Gestures::None; + bool touching = false; + bool isValid = false; + }; + } + + namespace Interface { + template + requires IsTouchPanel + class Touchpanel { + public: + explicit Touchpanel(T& impl) : impl {impl} {} + Touchpanel(const Touchpanel&) = delete; + Touchpanel& operator=(const Touchpanel&) = delete; + Touchpanel(Touchpanel&&) = delete; + Touchpanel& operator=(Touchpanel&&) = delete; + + bool Init() { + return impl.Init(); + } + + TouchPanels::TouchInfos GetTouchInfo() { + return impl.GetTouchInfo(); + } + + void Sleep() { + impl.Sleep(); + } + + void Wakeup() { + impl.Wakeup(); + } + + uint8_t GetChipId() const { + return impl.GetChipId(); + } + + uint8_t GetVendorId() const { + return impl.GetVendorId(); + } + + uint8_t GetFwVersion() const { + return impl.GetFwVersion(); + } + + private: + T& impl; + }; + } + } +} diff --git a/src/drivers/Cst816s.cpp b/src/drivers/touchpanels/Cst816s.cpp similarity index 95% rename from src/drivers/Cst816s.cpp rename to src/drivers/touchpanels/Cst816s.cpp index cf10c895..a55b5ae2 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/touchpanels/Cst816s.cpp @@ -1,11 +1,11 @@ -#include "drivers/Cst816s.h" +#include "Cst816s.h" #include #include #include #include #include "drivers/PinMap.h" -using namespace Pinetime::Drivers; +using namespace Pinetime::Drivers::TouchPanels; /* References : * This implementation is based on this article : @@ -59,8 +59,8 @@ bool Cst816S::Init() { return true; } -Cst816S::TouchInfos Cst816S::GetTouchInfo() { - Cst816S::TouchInfos info; +TouchInfos Cst816S::GetTouchInfo() { + TouchInfos info; uint8_t touchData[7]; auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData)); @@ -77,7 +77,7 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() { uint8_t yHigh = touchData[touchYHighIndex] & 0x0f; uint8_t yLow = touchData[touchYLowIndex]; uint16_t y = (yHigh << 8) | yLow; - Gestures gesture = static_cast(touchData[gestureIndex]); + auto gesture = static_cast(touchData[gestureIndex]); // Validity check if (x >= maxX || y >= maxY || diff --git a/src/drivers/touchpanels/Cst816s.h b/src/drivers/touchpanels/Cst816s.h new file mode 100644 index 00000000..70d6ee16 --- /dev/null +++ b/src/drivers/touchpanels/Cst816s.h @@ -0,0 +1,60 @@ +#pragma once +#include +#include "port/TwiMaster.h" +#include "drivers/TouchPanel.h" + +namespace Pinetime { + namespace Drivers { + namespace TouchPanels{ + class Cst816S { + public: + Cst816S(TwiMaster& twiMaster, uint8_t twiAddress); + Cst816S(const Cst816S&) = delete; + Cst816S& operator=(const Cst816S&) = delete; + Cst816S(Cst816S&&) = delete; + Cst816S& operator=(Cst816S&&) = delete; + + bool Init(); + TouchPanels::TouchInfos GetTouchInfo(); + void Sleep(); + void Wakeup(); + + uint8_t GetChipId() const { + return chipId; + } + uint8_t GetVendorId() const { + return vendorId; + } + uint8_t GetFwVersion() const { + return fwVersion; + } + + private: + bool CheckDeviceIds(); + + // Unused/Unavailable commented out + static constexpr uint8_t gestureIndex = 1; + static constexpr uint8_t touchPointNumIndex = 2; + // static constexpr uint8_t touchEventIndex = 3; + static constexpr uint8_t touchXHighIndex = 3; + static constexpr uint8_t touchXLowIndex = 4; + // static constexpr uint8_t touchIdIndex = 5; + static constexpr uint8_t touchYHighIndex = 5; + static constexpr uint8_t touchYLowIndex = 6; + // static constexpr uint8_t touchStep = 6; + // static constexpr uint8_t touchXYIndex = 7; + // static constexpr uint8_t touchMiscIndex = 8; + + static constexpr uint8_t maxX = 240; + static constexpr uint8_t maxY = 240; + + TwiMaster& twiMaster; + uint8_t twiAddress; + + uint8_t chipId; + uint8_t vendorId; + uint8_t fwVersion; + }; + } + } +} diff --git a/src/main.cpp b/src/main.cpp index 17fd1bd7..63baa71d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,7 +43,7 @@ #include "drivers/SpiNorFlash.h" #include "drivers/St7789.h" #include "drivers/TwiMaster.h" -#include "drivers/Cst816s.h" +#include "drivers/touchpanels/Cst816s.h" #include "drivers/PinMap.h" #include "systemtask/SystemTask.h" #include "drivers/PinMap.h" @@ -59,6 +59,7 @@ Pinetime::Logging::DummyLogger logger; #endif #include "port/infinitime.h" +#include "port/TouchPanel.h" static constexpr uint8_t touchPanelTwiAddress = 0x15; static constexpr uint8_t motionSensorTwiAddress = 0x18; @@ -90,7 +91,8 @@ Pinetime::Drivers::SpiNorFlash spiNorFlash {spiNorFlashImpl}; static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000}; Pinetime::Drivers::Nrf52::TwiMaster twiMasterImpl {NRF_TWIM1, MaxTwiFrequencyWithoutHardwareBug, Pinetime::PinMap::TwiSda, Pinetime::PinMap::TwiScl}; Pinetime::Drivers::TwiMaster twiMaster{twiMasterImpl}; -Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress}; +Pinetime::Drivers::TouchPanels::Cst816S touchPanelImpl {twiMaster, touchPanelTwiAddress}; +Pinetime::Drivers::TouchPanel touchPanel {touchPanelImpl}; #ifdef PINETIME_IS_RECOVERY #include "displayapp/DummyLittleVgl.h" #include "displayapp/DisplayAppRecovery.h" diff --git a/src/port/TouchPanel.h b/src/port/TouchPanel.h new file mode 100644 index 00000000..d1df252b --- /dev/null +++ b/src/port/TouchPanel.h @@ -0,0 +1,16 @@ +#pragma once +#include "drivers/TouchPanel.h" + +#ifdef TARGET_DEVICE_PINETIME + #include +#endif + +namespace Pinetime { + namespace Drivers { +#ifdef TARGET_DEVICE_PINETIME + using TouchPanel = Interface::Touchpanel; +#else + #error "No target device specified!" +#endif + } +} diff --git a/src/port/TwiMaster.h b/src/port/TwiMaster.h new file mode 100644 index 00000000..9134f033 --- /dev/null +++ b/src/port/TwiMaster.h @@ -0,0 +1,16 @@ +#pragma once +#include "drivers/TwiMaster.h" + +#ifdef TARGET_DEVICE_PINETIME + #include +#endif + +namespace Pinetime { + namespace Drivers { +#ifdef TARGET_DEVICE_PINETIME + using TwiMaster = Interface::TwiMaster; +#else + #error "No target device specified!" +#endif + } +} diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index b93d3da2..79765105 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -6,7 +6,6 @@ #include "components/battery/BatteryController.h" #include "components/ble/BleController.h" #include "displayapp/TouchEvents.h" -#include "drivers/Cst816s.h" #include "drivers/St7789.h" #include "drivers/Hrs3300.h" #include "drivers/PinMap.h" @@ -44,7 +43,7 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi, Drivers::St7789& lcd, Pinetime::Drivers::SpiNorFlash& spiNorFlash, Drivers::TwiMaster& twiMaster, - Drivers::Cst816S& touchPanel, + Pinetime::Drivers::TouchPanel& touchPanel, Components::LittleVgl& lvgl, Controllers::Battery& batteryController, Controllers::Ble& bleController, diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index 6be19bc1..4b562786 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -40,7 +40,6 @@ extern std::chrono::time_point NoInit_BackUpTime; namespace Pinetime { namespace Drivers { - class Cst816S; class St7789; class Hrs3300; } @@ -57,7 +56,7 @@ namespace Pinetime { Drivers::St7789& lcd, Pinetime::Drivers::SpiNorFlash& spiNorFlash, Drivers::TwiMaster& twiMaster, - Drivers::Cst816S& touchPanel, + Pinetime::Drivers::TouchPanel& touchPanel, Components::LittleVgl& lvgl, Controllers::Battery& batteryController, Controllers::Ble& bleController, @@ -101,7 +100,7 @@ namespace Pinetime { Pinetime::Drivers::St7789& lcd; Pinetime::Drivers::SpiNorFlash& spiNorFlash; Pinetime::Drivers::TwiMaster& twiMaster; - Pinetime::Drivers::Cst816S& touchPanel; + Pinetime::Drivers::TouchPanel& touchPanel; Pinetime::Components::LittleVgl& lvgl; Pinetime::Controllers::Battery& batteryController; diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp index 0e4fb541..1a49d679 100644 --- a/src/touchhandler/TouchHandler.cpp +++ b/src/touchhandler/TouchHandler.cpp @@ -9,30 +9,30 @@ using namespace Pinetime::Controllers; using namespace Pinetime::Applications; namespace { - TouchEvents ConvertGesture(Pinetime::Drivers::Cst816S::Gestures gesture) { + TouchEvents ConvertGesture(Pinetime::Drivers::TouchPanels::Gestures gesture) { switch (gesture) { - case Pinetime::Drivers::Cst816S::Gestures::SingleTap: + case Pinetime::Drivers::TouchPanels::Gestures::SingleTap: return TouchEvents::Tap; - case Pinetime::Drivers::Cst816S::Gestures::LongPress: + case Pinetime::Drivers::TouchPanels::Gestures::LongPress: return TouchEvents::LongTap; - case Pinetime::Drivers::Cst816S::Gestures::DoubleTap: + case Pinetime::Drivers::TouchPanels::Gestures::DoubleTap: return TouchEvents::DoubleTap; - case Pinetime::Drivers::Cst816S::Gestures::SlideRight: + case Pinetime::Drivers::TouchPanels::Gestures::SlideRight: return TouchEvents::SwipeRight; - case Pinetime::Drivers::Cst816S::Gestures::SlideLeft: + case Pinetime::Drivers::TouchPanels::Gestures::SlideLeft: return TouchEvents::SwipeLeft; - case Pinetime::Drivers::Cst816S::Gestures::SlideDown: + case Pinetime::Drivers::TouchPanels::Gestures::SlideDown: return TouchEvents::SwipeDown; - case Pinetime::Drivers::Cst816S::Gestures::SlideUp: + case Pinetime::Drivers::TouchPanels::Gestures::SlideUp: return TouchEvents::SwipeUp; - case Pinetime::Drivers::Cst816S::Gestures::None: + case Pinetime::Drivers::TouchPanels::Gestures::None: default: return TouchEvents::None; } } } -TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl& lvgl) : touchPanel {touchPanel}, lvgl {lvgl} { +TouchHandler::TouchHandler(Pinetime::Drivers::TouchPanel& touchPanel, Components::LittleVgl& lvgl) : touchPanel {touchPanel}, lvgl {lvgl} { } void TouchHandler::CancelTap() { @@ -55,13 +55,13 @@ bool TouchHandler::GetNewTouchInfo() { return false; } - if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { + if (info.gesture != Pinetime::Drivers::TouchPanels::Gestures::None) { if (gestureReleased) { - if (info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideDown || - info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideLeft || - info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideUp || - info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideRight || - info.gesture == Pinetime::Drivers::Cst816S::Gestures::LongPress) { + if (info.gesture == Pinetime::Drivers::TouchPanels::Gestures::SlideDown || + info.gesture == Pinetime::Drivers::TouchPanels::Gestures::SlideLeft || + info.gesture == Pinetime::Drivers::TouchPanels::Gestures::SlideUp || + info.gesture == Pinetime::Drivers::TouchPanels::Gestures::SlideRight || + info.gesture == Pinetime::Drivers::TouchPanels::Gestures::LongPress) { if (info.touching) { gesture = ConvertGesture(info.gesture); gestureReleased = false; diff --git a/src/touchhandler/TouchHandler.h b/src/touchhandler/TouchHandler.h index 332041e5..aa47b190 100644 --- a/src/touchhandler/TouchHandler.h +++ b/src/touchhandler/TouchHandler.h @@ -1,18 +1,16 @@ #pragma once -#include "drivers/Cst816s.h" +#include "port/TouchPanel.h" #include "displayapp/TouchEvents.h" namespace Pinetime { namespace Components { class LittleVgl; } - namespace Drivers { - class Cst816S; - } + namespace Controllers { class TouchHandler { public: - explicit TouchHandler(Drivers::Cst816S&, Components::LittleVgl&); + explicit TouchHandler(Pinetime::Drivers::TouchPanel&, Components::LittleVgl&); void CancelTap(); bool GetNewTouchInfo(); void UpdateLvglTouchPoint(); @@ -29,8 +27,8 @@ namespace Pinetime { Pinetime::Applications::TouchEvents GestureGet(); private: - Pinetime::Drivers::Cst816S::TouchInfos info; - Pinetime::Drivers::Cst816S& touchPanel; + Pinetime::Drivers::TouchPanels::TouchInfos info; + Pinetime::Drivers::TouchPanel& touchPanel; Pinetime::Components::LittleVgl& lvgl; Pinetime::Applications::TouchEvents gesture; bool isCancelled = false;