From 2a3e1263906d1145d6b539ff019362f0077d8097 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Fri, 16 Jul 2021 00:07:55 +0300 Subject: Fix most issues --- src/drivers/Cst816s.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/drivers/Cst816s.h') diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index 14c296ea..26bdf4e0 100644 --- a/src/drivers/Cst816s.h +++ b/src/drivers/Cst816s.h @@ -19,12 +19,9 @@ namespace Pinetime { struct TouchInfos { uint16_t x = 0; uint16_t y = 0; - uint8_t action = 0; - uint8_t finger = 0; - uint8_t pressure = 0; - uint8_t area = 0; Gestures gesture = Gestures::None; - bool isTouch = false; + bool touching = false; + bool isValid = false; }; Cst816S(TwiMaster& twiMaster, uint8_t twiAddress); @@ -41,23 +38,24 @@ namespace Pinetime { private: static constexpr uint8_t pinIrq = 28; static constexpr uint8_t pinReset = 10; - static constexpr uint8_t lastTouchId = 0x0f; + + // Unused/Unavailable commented out + static constexpr uint8_t gestureIndex = 1; static constexpr uint8_t touchPointNumIndex = 2; - static constexpr uint8_t touchMiscIndex = 8; - static constexpr uint8_t touchXYIndex = 7; - static constexpr uint8_t touchEventIndex = 3; + //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 touchIdIndex = 5; - static constexpr uint8_t touchStep = 6; - static constexpr uint8_t gestureIndex = 1; + //static constexpr uint8_t touchStep = 6; + //static constexpr uint8_t touchXYIndex = 7; + //static constexpr uint8_t touchMiscIndex = 8; - uint8_t touchData[10]; + uint8_t touchData[7]; TwiMaster& twiMaster; uint8_t twiAddress; }; } -} \ No newline at end of file +} -- cgit v1.2.3 From 3e42297bd86fa20daaf7f59f6bc0a69de6cf9e53 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Sun, 18 Jul 2021 12:32:46 +0300 Subject: Update --- src/drivers/Cst816s.h | 2 +- src/main.cpp | 3 --- src/systemtask/SystemTask.cpp | 3 +++ src/touchhandler/TouchHandler.cpp | 44 ++++++++++++++++++++------------------- 4 files changed, 27 insertions(+), 25 deletions(-) (limited to 'src/drivers/Cst816s.h') diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index 26bdf4e0..d4c17bb8 100644 --- a/src/drivers/Cst816s.h +++ b/src/drivers/Cst816s.h @@ -21,7 +21,7 @@ namespace Pinetime { uint16_t y = 0; Gestures gesture = Gestures::None; bool touching = false; - bool isValid = false; + bool isValid = true; }; Cst816S(TwiMaster& twiMaster, uint8_t twiAddress); diff --git a/src/main.cpp b/src/main.cpp index b8d4b023..62e4446f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -315,9 +315,6 @@ int main(void) { systemTask.Start(); - touchHandler.Register(&systemTask); - touchHandler.Start(); - nimble_port_init(); vTaskStartScheduler(); diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 93d19863..252d3cc3 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -144,6 +144,9 @@ void SystemTask::Work() { heartRateSensor.Disable(); heartRateApp.Start(); + touchHandler.Register(this); + touchHandler.Start(); + nrf_gpio_cfg_sense_input(pinButton, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_High); nrf_gpio_cfg_output(15); nrf_gpio_pin_set(15); diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp index 0d0b8273..187aa696 100644 --- a/src/touchhandler/TouchHandler.cpp +++ b/src/touchhandler/TouchHandler.cpp @@ -30,37 +30,39 @@ void TouchHandler::Process(void* instance) { } void TouchHandler::Work() { - Pinetime::Drivers::Cst816S::Gestures prevGesture = Pinetime::Drivers::Cst816S::Gestures::None; + bool slideReleased = true; while (true) { vTaskSuspend(taskHandle); info = touchPanel.GetTouchInfo(); - if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { - if (prevGesture != info.gesture) { - 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) { - prevGesture = info.gesture; + if (info.isValid) { + if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { + if (slideReleased) { + 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) { + slideReleased = false; + } + gesture = info.gesture; } - gesture = info.gesture; } - } - if (systemTask->IsSleeping()) { - systemTask->PushMessage(System::Messages::TouchWakeUp); - } else { - if (info.touching) { - if (!isCancelled) { - lvgl.SetNewTouchPoint(info.x, info.y, true); - } - } else { - if (isCancelled) { - lvgl.SetNewTouchPoint(-1, -1, false); - isCancelled = false; + if (!systemTask->IsSleeping()) { + if (info.touching) { + if (!isCancelled) { + lvgl.SetNewTouchPoint(info.x, info.y, true); + } } else { - lvgl.SetNewTouchPoint(info.x, info.y, false); + if (isCancelled) { + lvgl.SetNewTouchPoint(-1, -1, false); + isCancelled = false; + } else { + lvgl.SetNewTouchPoint(info.x, info.y, false); + } + slideReleased = true; } - prevGesture = Pinetime::Drivers::Cst816S::Gestures::None; } systemTask->OnTouchEvent(); } -- cgit v1.2.3