Skip to content

Commit 828e849

Browse files
committed
test: Add touch logging
Roll this commit back once touch is working
1 parent d968b20 commit 828e849

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Drivers/EspLcdCompat/Source/EspLcdTouch.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@
66

77
constexpr const char* TAG = "EspLcdTouch";
88

9+
// Enable this to log all touch events (can be very verbose)
10+
#define LOG_TOUCH_EVENTS 1
11+
12+
#if LOG_TOUCH_EVENTS
13+
static void touch_event_callback(lv_event_t* e) {
14+
TT_LOG_I(TAG, "Touch event callback triggered");
15+
lv_event_code_t code = lv_event_get_code(e);
16+
lv_indev_t* indev = (lv_indev_t*)lv_event_get_target(e);
17+
18+
// Get the last point from the indev
19+
lv_point_t point;
20+
lv_indev_get_point(indev, &point);
21+
22+
if (code == LV_EVENT_PRESSED) {
23+
TT_LOG_I(TAG, "Touch: state=PRESSED, x=%d, y=%d", point.x, point.y);
24+
} else if (code == LV_EVENT_PRESSING) {
25+
TT_LOG_I(TAG, "Touch: state=PRESSING, x=%d, y=%d", point.x, point.y);
26+
} else if (code == LV_EVENT_RELEASED) {
27+
TT_LOG_I(TAG, "Touch: state=RELEASED");
28+
}
29+
}
30+
#endif
31+
932
bool EspLcdTouch::start() {
1033
if (!createIoHandle(ioHandle) != ESP_OK) {
1134
TT_LOG_E(TAG, "Touch IO failed");
@@ -63,6 +86,14 @@ bool EspLcdTouch::startLvgl(lv_disp_t* display) {
6386
return false;
6487
}
6588

89+
#if LOG_TOUCH_EVENTS
90+
// Add event listener to log touch events
91+
lv_indev_add_event_cb(lvglDevice, touch_event_callback, LV_EVENT_PRESSED, nullptr);
92+
lv_indev_add_event_cb(lvglDevice, touch_event_callback, LV_EVENT_PRESSING, nullptr);
93+
lv_indev_add_event_cb(lvglDevice, touch_event_callback, LV_EVENT_RELEASED, nullptr);
94+
TT_LOG_I(TAG, "Touch event logging enabled");
95+
#endif
96+
6697
return true;
6798
}
6899

0 commit comments

Comments
 (0)