This commit is contained in:
Riku Isokoski 2021-07-18 12:32:46 +03:00
parent 329482f873
commit 3e42297bd8
4 changed files with 27 additions and 25 deletions

View file

@ -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);

View file

@ -315,9 +315,6 @@ int main(void) {
systemTask.Start();
touchHandler.Register(&systemTask);
touchHandler.Start();
nimble_port_init();
vTaskStartScheduler();

View file

@ -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);

View file

@ -30,25 +30,26 @@ 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.isValid) {
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 (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;
}
}
if (systemTask->IsSleeping()) {
systemTask->PushMessage(System::Messages::TouchWakeUp);
} else {
if (!systemTask->IsSleeping()) {
if (info.touching) {
if (!isCancelled) {
lvgl.SetNewTouchPoint(info.x, info.y, true);
@ -60,7 +61,8 @@ void TouchHandler::Work() {
} else {
lvgl.SetNewTouchPoint(info.x, info.y, false);
}
prevGesture = Pinetime::Drivers::Cst816S::Gestures::None;
slideReleased = true;
}
}
systemTask->OnTouchEvent();
}