mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2026-05-05 20:26:39 +02:00
Refactor Cst816S as a generic class that implements the concept IsTouchPanel.
This commit is contained in:
parent
ddcf491e2e
commit
2094dbdab3
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
#include <bits/unique_ptr.h>
|
||||
#include <queue.h>
|
||||
#include "components/gfx/Gfx.h"
|
||||
#include "drivers/Cst816s.h"
|
||||
#include <date/date.h>
|
||||
#include <drivers/Watchdog.h>
|
||||
#include <components/motor/MotorController.h>
|
||||
@ -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,
|
||||
|
||||
@ -4,14 +4,14 @@
|
||||
#include <lvgl/src/lv_themes/lv_theme.h>
|
||||
#include <lvgl/src/lv_hal/lv_hal.h>
|
||||
#include <drivers/St7789.h>
|
||||
#include <drivers/Cst816s.h>
|
||||
#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;
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
//#include <projdefs.h>
|
||||
#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() {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#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];
|
||||
|
||||
@ -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},
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
83
src/drivers/TouchPanel.h
Normal file
83
src/drivers/TouchPanel.h
Normal file
@ -0,0 +1,83 @@
|
||||
#pragma once
|
||||
#include <concepts>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Drivers {
|
||||
template <typename touchpanelImpl>
|
||||
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 <class T>
|
||||
requires IsTouchPanel<T>
|
||||
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
#include "drivers/Cst816s.h"
|
||||
#include "Cst816s.h"
|
||||
#include <FreeRTOS.h>
|
||||
#include <legacy/nrf_drv_gpiote.h>
|
||||
#include <nrfx_log.h>
|
||||
#include <task.h>
|
||||
#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<Gestures>(touchData[gestureIndex]);
|
||||
auto gesture = static_cast<Gestures>(touchData[gestureIndex]);
|
||||
|
||||
// Validity check
|
||||
if (x >= maxX || y >= maxY ||
|
||||
60
src/drivers/touchpanels/Cst816s.h
Normal file
60
src/drivers/touchpanels/Cst816s.h
Normal file
@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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"
|
||||
|
||||
16
src/port/TouchPanel.h
Normal file
16
src/port/TouchPanel.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "drivers/TouchPanel.h"
|
||||
|
||||
#ifdef TARGET_DEVICE_PINETIME
|
||||
#include <drivers/touchpanels/Cst816s.h>
|
||||
#endif
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Drivers {
|
||||
#ifdef TARGET_DEVICE_PINETIME
|
||||
using TouchPanel = Interface::Touchpanel<Pinetime::Drivers::TouchPanels::Cst816S>;
|
||||
#else
|
||||
#error "No target device specified!"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
16
src/port/TwiMaster.h
Normal file
16
src/port/TwiMaster.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "drivers/TwiMaster.h"
|
||||
|
||||
#ifdef TARGET_DEVICE_PINETIME
|
||||
#include <drivers/nrf52/TwiMaster.h>
|
||||
#endif
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Drivers {
|
||||
#ifdef TARGET_DEVICE_PINETIME
|
||||
using TwiMaster = Interface::TwiMaster<Pinetime::Drivers::Nrf52::TwiMaster>;
|
||||
#else
|
||||
#error "No target device specified!"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -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,
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
extern std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> 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;
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user