Merge branch 'fix_touchevent_tap' of git://github.com/Riksu9000/InfiniTime into Riksu9000-fix_touchevent_tap

# Conflicts:
#	src/displayapp/DisplayApp.cpp
This commit is contained in:
Jean-François Milants 2021-07-24 18:46:52 +02:00
commit 926553d043
4 changed files with 33 additions and 40 deletions

View File

@ -52,6 +52,31 @@ namespace {
static inline bool in_isr(void) {
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
}
TouchEvents Convert(Pinetime::Drivers::Cst816S::TouchInfos info) {
if (info.isTouch) {
switch (info.gesture) {
case Pinetime::Drivers::Cst816S::Gestures::SingleTap:
return TouchEvents::Tap;
case Pinetime::Drivers::Cst816S::Gestures::LongPress:
return TouchEvents::LongTap;
case Pinetime::Drivers::Cst816S::Gestures::DoubleTap:
return TouchEvents::DoubleTap;
case Pinetime::Drivers::Cst816S::Gestures::SlideRight:
return TouchEvents::SwipeRight;
case Pinetime::Drivers::Cst816S::Gestures::SlideLeft:
return TouchEvents::SwipeLeft;
case Pinetime::Drivers::Cst816S::Gestures::SlideDown:
return TouchEvents::SwipeDown;
case Pinetime::Drivers::Cst816S::Gestures::SlideUp:
return TouchEvents::SwipeUp;
case Pinetime::Drivers::Cst816S::Gestures::None:
default:
return TouchEvents::None;
}
}
return TouchEvents::None;
}
}
DisplayApp::DisplayApp(Drivers::St7789& lcd,
@ -180,7 +205,8 @@ void DisplayApp::Refresh() {
if (state != States::Running) {
break;
}
auto gesture = OnTouchEvent();
auto info = touchPanel.GetTouchInfo();
auto gesture = Convert(info);
if (gesture == TouchEvents::None) {
break;
}
@ -204,6 +230,10 @@ void DisplayApp::Refresh() {
}
} else if (returnTouchEvent == gesture) {
LoadApp(returnToApp, returnDirection);
} else if (touchMode == TouchModes::Gestures) {
if (gesture == TouchEvents::Tap) {
lvgl.SetNewTapEvent(info.x, info.y);
}
}
}
} break;
@ -400,35 +430,6 @@ void DisplayApp::PushMessage(Messages msg) {
}
}
TouchEvents DisplayApp::OnTouchEvent() {
auto info = touchPanel.GetTouchInfo();
if (info.isTouch) {
switch (info.gesture) {
case Pinetime::Drivers::Cst816S::Gestures::SingleTap:
if (touchMode == TouchModes::Gestures) {
lvgl.SetNewTapEvent(info.x, info.y);
}
return TouchEvents::Tap;
case Pinetime::Drivers::Cst816S::Gestures::LongPress:
return TouchEvents::LongTap;
case Pinetime::Drivers::Cst816S::Gestures::DoubleTap:
return TouchEvents::DoubleTap;
case Pinetime::Drivers::Cst816S::Gestures::SlideRight:
return TouchEvents::SwipeRight;
case Pinetime::Drivers::Cst816S::Gestures::SlideLeft:
return TouchEvents::SwipeLeft;
case Pinetime::Drivers::Cst816S::Gestures::SlideDown:
return TouchEvents::SwipeDown;
case Pinetime::Drivers::Cst816S::Gestures::SlideUp:
return TouchEvents::SwipeUp;
case Pinetime::Drivers::Cst816S::Gestures::None:
default:
return TouchEvents::None;
}
}
return TouchEvents::None;
}
void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) {
switch (direction) {
case DisplayApp::FullRefreshDirections::Down:

View File

@ -102,7 +102,6 @@ namespace Pinetime {
TouchModes touchMode = TouchModes::Gestures;
TouchEvents OnTouchEvent();
void RunningState();
void IdleState();
static void Process(void* instance);

View File

@ -70,5 +70,5 @@ bool FlashLight::Refresh() {
}
bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return true;
return false;
}

View File

@ -155,14 +155,7 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
}
bool QuickSettings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) {
case Pinetime::Applications::TouchEvents::SwipeLeft:
running = false;
return false;
default:
return true;
}
}
bool QuickSettings::Refresh() {