touchhandler: Remove LVGL dependency
Move LVGL specific code to the LittleVgl class
This commit is contained in:
@@ -222,6 +222,7 @@ void DisplayApp::Refresh() {
|
||||
if (state != States::Running) {
|
||||
break;
|
||||
}
|
||||
lvgl.SetNewTouchPoint(touchHandler.GetX(), touchHandler.GetY(), touchHandler.IsTouching());
|
||||
auto gesture = touchHandler.GestureGet();
|
||||
if (gesture == TouchEvents::None) {
|
||||
break;
|
||||
@@ -261,7 +262,7 @@ void DisplayApp::Refresh() {
|
||||
LoadPreviousScreen();
|
||||
}
|
||||
} else {
|
||||
touchHandler.CancelTap();
|
||||
lvgl.CancelTap();
|
||||
}
|
||||
} break;
|
||||
case Messages::ButtonPushed:
|
||||
@@ -339,7 +340,7 @@ void DisplayApp::LoadNewScreen(Apps app, DisplayApp::FullRefreshDirections direc
|
||||
}
|
||||
|
||||
void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections direction) {
|
||||
touchHandler.CancelTap();
|
||||
lvgl.CancelTap();
|
||||
ApplyBrightness();
|
||||
|
||||
currentScreen.reset(nullptr);
|
||||
|
||||
@@ -179,15 +179,34 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) {
|
||||
lv_disp_flush_ready(&disp_drv);
|
||||
}
|
||||
|
||||
void LittleVgl::SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) {
|
||||
tap_x = x;
|
||||
tap_y = y;
|
||||
tapped = contact;
|
||||
void LittleVgl::SetNewTouchPoint(int16_t x, int16_t y, bool contact) {
|
||||
if (contact) {
|
||||
if (!isCancelled) {
|
||||
touchPoint = {x, y};
|
||||
tapped = true;
|
||||
}
|
||||
} else {
|
||||
if (isCancelled) {
|
||||
touchPoint = {-1, -1};
|
||||
tapped = false;
|
||||
isCancelled = false;
|
||||
} else {
|
||||
touchPoint = {x, y};
|
||||
tapped = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LittleVgl::CancelTap() {
|
||||
if (tapped) {
|
||||
isCancelled = true;
|
||||
touchPoint = {-1, -1};
|
||||
}
|
||||
}
|
||||
|
||||
bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
|
||||
ptr->point.x = tap_x;
|
||||
ptr->point.y = tap_y;
|
||||
ptr->point.x = touchPoint.x;
|
||||
ptr->point.y = touchPoint.y;
|
||||
if (tapped) {
|
||||
ptr->state = LV_INDEV_STATE_PR;
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,8 @@ namespace Pinetime {
|
||||
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p);
|
||||
bool GetTouchPadInfo(lv_indev_data_t* ptr);
|
||||
void SetFullRefresh(FullRefreshDirections direction);
|
||||
void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact);
|
||||
void SetNewTouchPoint(int16_t x, int16_t y, bool contact);
|
||||
void CancelTap();
|
||||
|
||||
bool GetFullRefresh() {
|
||||
bool returnValue = fullRefresh;
|
||||
@@ -58,9 +59,9 @@ namespace Pinetime {
|
||||
uint16_t writeOffset = 0;
|
||||
uint16_t scrollOffset = 0;
|
||||
|
||||
uint16_t tap_x = 0;
|
||||
uint16_t tap_y = 0;
|
||||
lv_point_t touchPoint = {0};
|
||||
bool tapped = false;
|
||||
bool isCancelled = false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user