1
0
Fork 0

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) { static inline bool in_isr(void) {
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0; 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, DisplayApp::DisplayApp(Drivers::St7789& lcd,
@ -180,7 +205,8 @@ void DisplayApp::Refresh() {
if (state != States::Running) { if (state != States::Running) {
break; break;
} }
auto gesture = OnTouchEvent(); auto info = touchPanel.GetTouchInfo();
auto gesture = Convert(info);
if (gesture == TouchEvents::None) { if (gesture == TouchEvents::None) {
break; break;
} }
@ -204,6 +230,10 @@ void DisplayApp::Refresh() {
} }
} else if (returnTouchEvent == gesture) { } else if (returnTouchEvent == gesture) {
LoadApp(returnToApp, returnDirection); LoadApp(returnToApp, returnDirection);
} else if (touchMode == TouchModes::Gestures) {
if (gesture == TouchEvents::Tap) {
lvgl.SetNewTapEvent(info.x, info.y);
}
} }
} }
} break; } 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) { void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) {
switch (direction) { switch (direction) {
case DisplayApp::FullRefreshDirections::Down: case DisplayApp::FullRefreshDirections::Down:

View file

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

View file

@ -70,5 +70,5 @@ bool FlashLight::Refresh() {
} }
bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) { 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) { bool QuickSettings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) { return false;
case Pinetime::Applications::TouchEvents::SwipeLeft:
running = false;
return false;
default:
return true;
}
} }
bool QuickSettings::Refresh() { bool QuickSettings::Refresh() {