Skip to content

Commit 1516b08

Browse files
committed
TouchHandler: Do not store touch panel reference
1 parent 7066ff5 commit 1516b08

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
lines changed

src/displayapp/LittleVgl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace Pinetime {
5959
uint16_t writeOffset = 0;
6060
uint16_t scrollOffset = 0;
6161

62-
lv_point_t touchPoint = {0};
62+
lv_point_t touchPoint = {};
6363
bool tapped = false;
6464
bool isCancelled = false;
6565
};

src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Pinetime::Controllers::NotificationManager notificationManager;
111111
Pinetime::Controllers::MotionController motionController;
112112
Pinetime::Controllers::TimerController timerController;
113113
Pinetime::Controllers::AlarmController alarmController {dateTimeController};
114-
Pinetime::Controllers::TouchHandler touchHandler(touchPanel);
114+
Pinetime::Controllers::TouchHandler touchHandler;
115115
Pinetime::Controllers::ButtonHandler buttonHandler;
116116
Pinetime::Controllers::BrightnessController brightnessController {};
117117

src/systemtask/SystemTask.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void SystemTask::Work() {
250250
isDimmed = false;
251251
break;
252252
case Messages::TouchWakeUp: {
253-
if (touchHandler.GetNewTouchInfo()) {
253+
if (touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo())) {
254254
auto gesture = touchHandler.GestureGet();
255255
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
256256
gesture != Pinetime::Applications::TouchEvents::None &&
@@ -342,7 +342,7 @@ void SystemTask::Work() {
342342
// TODO add intent of fs access icon or something
343343
break;
344344
case Messages::OnTouchEvent:
345-
if (touchHandler.GetNewTouchInfo()) {
345+
if (touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo())) {
346346
ReloadIdleTimer();
347347
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
348348
}

src/touchhandler/TouchHandler.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,13 @@ namespace {
2727
}
2828
}
2929

30-
TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel) : touchPanel {touchPanel} {
31-
}
32-
3330
Pinetime::Applications::TouchEvents TouchHandler::GestureGet() {
3431
auto returnGesture = gesture;
3532
gesture = Pinetime::Applications::TouchEvents::None;
3633
return returnGesture;
3734
}
3835

39-
bool TouchHandler::GetNewTouchInfo() {
40-
info = touchPanel.GetTouchInfo();
41-
36+
bool TouchHandler::ProcessTouchInfo(Drivers::Cst816S::TouchInfos info) {
4237
if (!info.isValid) {
4338
return false;
4439
}
@@ -65,5 +60,7 @@ bool TouchHandler::GetNewTouchInfo() {
6560
gestureReleased = true;
6661
}
6762

63+
currentTouchPoint = {info.x, info.y, info.touching};
64+
6865
return true;
6966
}

src/touchhandler/TouchHandler.h

+10-12
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,34 @@
33
#include "displayapp/TouchEvents.h"
44

55
namespace Pinetime {
6-
namespace Drivers {
7-
class Cst816S;
8-
}
9-
106
namespace Controllers {
117
class TouchHandler {
128
public:
13-
explicit TouchHandler(Drivers::Cst816S&);
9+
struct TouchPoint {
10+
int x;
11+
int y;
12+
bool touching;
13+
};
1414

15-
bool GetNewTouchInfo();
15+
bool ProcessTouchInfo(Drivers::Cst816S::TouchInfos info);
1616

1717
bool IsTouching() const {
18-
return info.touching;
18+
return currentTouchPoint.touching;
1919
}
2020

2121
uint8_t GetX() const {
22-
return info.x;
22+
return currentTouchPoint.x;
2323
}
2424

2525
uint8_t GetY() const {
26-
return info.y;
26+
return currentTouchPoint.y;
2727
}
2828

2929
Pinetime::Applications::TouchEvents GestureGet();
3030

3131
private:
32-
Pinetime::Drivers::Cst816S::TouchInfos info;
33-
Pinetime::Drivers::Cst816S& touchPanel;
3432
Pinetime::Applications::TouchEvents gesture;
35-
bool isCancelled = false;
33+
TouchPoint currentTouchPoint = {};
3634
bool gestureReleased = true;
3735
};
3836
}

0 commit comments

Comments
 (0)