Fix touch wakeup and code cleanup
This commit is contained in:
parent
2a3e126390
commit
93ccbf38e8
|
@ -181,27 +181,6 @@ bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
|
||||||
ptr->state = LV_INDEV_STATE_REL;
|
ptr->state = LV_INDEV_STATE_REL;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
/*
|
|
||||||
auto info = touchPanel.GetTouchInfo();
|
|
||||||
|
|
||||||
if((previousClick.x != info.x || previousClick.y != info.y) &&
|
|
||||||
(info.gesture == Drivers::Cst816S::Gestures::SingleTap)) {
|
|
||||||
// TODO For an unknown reason, the first touch is taken twice into account.
|
|
||||||
// 'firstTouch' is a quite'n'dirty workaound until I find a better solution
|
|
||||||
if(firstTouch) ptr->state = LV_INDEV_STATE_REL;
|
|
||||||
else ptr->state = LV_INDEV_STATE_PR;
|
|
||||||
firstTouch = false;
|
|
||||||
previousClick.x = info.x;
|
|
||||||
previousClick.y = info.y;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ptr->state = LV_INDEV_STATE_REL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr->point.x = info.x;
|
|
||||||
ptr->point.y = info.y;
|
|
||||||
return false;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LittleVgl::InitTheme() {
|
void LittleVgl::InitTheme() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {m
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwiMaster::Init() {
|
void TwiMaster::Init() {
|
||||||
|
sleeping = false;
|
||||||
if(mutex == nullptr)
|
if(mutex == nullptr)
|
||||||
mutex = xSemaphoreCreateBinary();
|
mutex = xSemaphoreCreateBinary();
|
||||||
|
|
||||||
|
@ -176,12 +177,15 @@ void TwiMaster::Sleep() {
|
||||||
nrf_gpio_cfg_default(6);
|
nrf_gpio_cfg_default(6);
|
||||||
nrf_gpio_cfg_default(7);
|
nrf_gpio_cfg_default(7);
|
||||||
NRF_LOG_INFO("[TWIMASTER] Sleep");
|
NRF_LOG_INFO("[TWIMASTER] Sleep");
|
||||||
|
sleeping = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwiMaster::Wakeup() {
|
void TwiMaster::Wakeup() {
|
||||||
|
if (sleeping) {
|
||||||
Init();
|
Init();
|
||||||
NRF_LOG_INFO("[TWIMASTER] Wakeup");
|
NRF_LOG_INFO("[TWIMASTER] Wakeup");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Sometimes, the TWIM device just freeze and never set the event EVENTS_LASTTX.
|
/* Sometimes, the TWIM device just freeze and never set the event EVENTS_LASTTX.
|
||||||
* This method disable and re-enable the peripheral so that it works again.
|
* This method disable and re-enable the peripheral so that it works again.
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace Pinetime {
|
||||||
uint8_t internalBuffer[maxDataSize + registerSize];
|
uint8_t internalBuffer[maxDataSize + registerSize];
|
||||||
uint32_t txStartedCycleCount = 0;
|
uint32_t txStartedCycleCount = 0;
|
||||||
static constexpr uint32_t HwFreezedDelay {161000};
|
static constexpr uint32_t HwFreezedDelay {161000};
|
||||||
|
bool sleeping;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -161,10 +161,12 @@ Pinetime::System::SystemTask systemTask(spi,
|
||||||
heartRateController,
|
heartRateController,
|
||||||
displayApp,
|
displayApp,
|
||||||
heartRateApp,
|
heartRateApp,
|
||||||
fs);
|
fs,
|
||||||
|
touchHandler);
|
||||||
|
|
||||||
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
|
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
|
||||||
if (pin == pinTouchIrq) {
|
if (pin == pinTouchIrq) {
|
||||||
|
twiMaster.Wakeup();
|
||||||
touchHandler.WakeUp();
|
touchHandler.WakeUp();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,8 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
|
||||||
Pinetime::Controllers::HeartRateController& heartRateController,
|
Pinetime::Controllers::HeartRateController& heartRateController,
|
||||||
Pinetime::Applications::DisplayApp& displayApp,
|
Pinetime::Applications::DisplayApp& displayApp,
|
||||||
Pinetime::Applications::HeartRateTask& heartRateApp,
|
Pinetime::Applications::HeartRateTask& heartRateApp,
|
||||||
Pinetime::Controllers::FS& fs)
|
Pinetime::Controllers::FS& fs,
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler)
|
||||||
: spi {spi},
|
: spi {spi},
|
||||||
lcd {lcd},
|
lcd {lcd},
|
||||||
spiNorFlash {spiNorFlash},
|
spiNorFlash {spiNorFlash},
|
||||||
|
@ -82,8 +83,8 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
|
||||||
displayApp {displayApp},
|
displayApp {displayApp},
|
||||||
heartRateApp(heartRateApp),
|
heartRateApp(heartRateApp),
|
||||||
fs {fs},
|
fs {fs},
|
||||||
|
touchHandler {touchHandler},
|
||||||
nimbleController(*this, bleController, dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) {
|
nimbleController(*this, bleController, dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTask::Start() {
|
void SystemTask::Start() {
|
||||||
|
@ -228,14 +229,14 @@ void SystemTask::Work() {
|
||||||
isWakingUp = false;
|
isWakingUp = false;
|
||||||
break;
|
break;
|
||||||
case Messages::TouchWakeUp: {
|
case Messages::TouchWakeUp: {
|
||||||
twiMaster.Wakeup();
|
auto gesture = touchHandler.GestureGet();
|
||||||
auto touchInfo = touchPanel.GetTouchInfo();
|
if ((gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap &&
|
||||||
twiMaster.Sleep();
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) ||
|
||||||
if (touchInfo.isValid and ((touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and
|
(gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap &&
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) or
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap))) {
|
||||||
(touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap and
|
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
|
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
|
} else {
|
||||||
|
twiMaster.Sleep();
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case Messages::GoToSleep:
|
case Messages::GoToSleep:
|
||||||
|
@ -417,7 +418,6 @@ void SystemTask::PushMessage(System::Messages msg) {
|
||||||
if (xHigherPriorityTaskWoken) {
|
if (xHigherPriorityTaskWoken) {
|
||||||
/* Actual macro used here is port specific. */
|
/* Actual macro used here is port specific. */
|
||||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
xQueueSend(systemTasksMsgQueue, &msg, portMAX_DELAY);
|
xQueueSend(systemTasksMsgQueue, &msg, portMAX_DELAY);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "components/motor/MotorController.h"
|
#include "components/motor/MotorController.h"
|
||||||
#include "components/timer/TimerController.h"
|
#include "components/timer/TimerController.h"
|
||||||
#include "components/fs/FS.h"
|
#include "components/fs/FS.h"
|
||||||
|
#include "touchhandler/TouchHandler.h"
|
||||||
|
|
||||||
#ifdef PINETIME_IS_RECOVERY
|
#ifdef PINETIME_IS_RECOVERY
|
||||||
#include "displayapp/DisplayAppRecovery.h"
|
#include "displayapp/DisplayAppRecovery.h"
|
||||||
|
@ -39,6 +40,9 @@ namespace Pinetime {
|
||||||
class TwiMaster;
|
class TwiMaster;
|
||||||
class Hrs3300;
|
class Hrs3300;
|
||||||
}
|
}
|
||||||
|
namespace Controllers {
|
||||||
|
class TouchHandler;
|
||||||
|
}
|
||||||
namespace System {
|
namespace System {
|
||||||
class SystemTask {
|
class SystemTask {
|
||||||
public:
|
public:
|
||||||
|
@ -62,7 +66,8 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::HeartRateController& heartRateController,
|
Pinetime::Controllers::HeartRateController& heartRateController,
|
||||||
Pinetime::Applications::DisplayApp& displayApp,
|
Pinetime::Applications::DisplayApp& displayApp,
|
||||||
Pinetime::Applications::HeartRateTask& heartRateApp,
|
Pinetime::Applications::HeartRateTask& heartRateApp,
|
||||||
Pinetime::Controllers::FS& fs);
|
Pinetime::Controllers::FS& fs,
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler);
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
void PushMessage(Messages msg);
|
void PushMessage(Messages msg);
|
||||||
|
@ -91,7 +96,6 @@ namespace Pinetime {
|
||||||
Pinetime::Components::LittleVgl& lvgl;
|
Pinetime::Components::LittleVgl& lvgl;
|
||||||
Pinetime::Controllers::Battery& batteryController;
|
Pinetime::Controllers::Battery& batteryController;
|
||||||
|
|
||||||
|
|
||||||
Pinetime::Controllers::Ble& bleController;
|
Pinetime::Controllers::Ble& bleController;
|
||||||
Pinetime::Controllers::DateTime& dateTimeController;
|
Pinetime::Controllers::DateTime& dateTimeController;
|
||||||
Pinetime::Controllers::TimerController& timerController;
|
Pinetime::Controllers::TimerController& timerController;
|
||||||
|
@ -113,6 +117,7 @@ namespace Pinetime {
|
||||||
Pinetime::Applications::DisplayApp& displayApp;
|
Pinetime::Applications::DisplayApp& displayApp;
|
||||||
Pinetime::Applications::HeartRateTask& heartRateApp;
|
Pinetime::Applications::HeartRateTask& heartRateApp;
|
||||||
Pinetime::Controllers::FS& fs;
|
Pinetime::Controllers::FS& fs;
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler;
|
||||||
Pinetime::Controllers::NimbleController nimbleController;
|
Pinetime::Controllers::NimbleController nimbleController;
|
||||||
|
|
||||||
static constexpr uint8_t pinSpiSck = 2;
|
static constexpr uint8_t pinSpiSck = 2;
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
using namespace Pinetime::Controllers;
|
using namespace Pinetime::Controllers;
|
||||||
|
|
||||||
TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl& lvgl)
|
TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl& lvgl) : touchPanel {touchPanel}, lvgl {lvgl} {
|
||||||
: touchPanel {touchPanel},
|
|
||||||
lvgl {lvgl} {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchHandler::CancelTap() {
|
void TouchHandler::CancelTap() {
|
||||||
|
@ -35,6 +33,7 @@ void TouchHandler::Work() {
|
||||||
vTaskSuspend(taskHandle);
|
vTaskSuspend(taskHandle);
|
||||||
info = touchPanel.GetTouchInfo();
|
info = touchPanel.GetTouchInfo();
|
||||||
if (systemTask->IsSleeping()) {
|
if (systemTask->IsSleeping()) {
|
||||||
|
gesture = info.gesture;
|
||||||
systemTask->PushMessage(System::Messages::TouchWakeUp);
|
systemTask->PushMessage(System::Messages::TouchWakeUp);
|
||||||
} else {
|
} else {
|
||||||
x = info.x;
|
x = info.x;
|
||||||
|
|
Loading…
Reference in New Issue