@@ -40,8 +40,12 @@ Arduino_GigaDisplayTouch * gThis;
40
40
41
41
/* Private function prototypes -----------------------------------------------*/
42
42
#if __has_include ("lvgl.h")
43
+ #if (LVGL_VERSION_MAJOR == 9)
44
+ void _lvglTouchCb (lv_indev_t * indev, lv_indev_data_t * data);
45
+ #else
43
46
void _lvglTouchCb (lv_indev_drv_t * indev, lv_indev_data_t * data);
44
47
#endif
48
+ #endif
45
49
46
50
/* Functions -----------------------------------------------------------------*/
47
51
Arduino_GigaDisplayTouch::Arduino_GigaDisplayTouch (TwoWire& wire, uint8_t intPin, uint8_t rstPin, uint8_t addr)
@@ -84,19 +88,42 @@ bool Arduino_GigaDisplayTouch::begin() {
84
88
uint8_t error = _gt911ReadOp (GT911_REG_CONFIG_VERSION, &testByte, 1 );
85
89
86
90
#if __has_include ("lvgl.h")
91
+ #if (LVGL_VERSION_MAJOR == 9)
92
+ static lv_indev_t * indev = lv_indev_create ();
93
+ lv_indev_set_type (indev, LV_INDEV_TYPE_POINTER);
94
+ lv_indev_set_read_cb (indev, _lvglTouchCb);
95
+ #else
87
96
static lv_indev_drv_t indev_drv; /* Descriptor of a input device driver */
88
97
lv_indev_drv_init (&indev_drv); /* Basic initialization */
89
- indev_drv.type = LV_INDEV_TYPE_POINTER; /* Touch pad is a pointer-like device */
98
+ indev_drv.type = LV_INDEV_TYPE_POINTER; /* Touch pad is a pointer-like device */
90
99
indev_drv.read_cb = _lvglTouchCb; /* Set your driver function */
91
100
lv_indev_t * my_indev = lv_indev_drv_register (&indev_drv); /* Register the driver in LVGL and save the created input device object */
92
-
93
- gThis = this ;
101
+ #endif
94
102
#endif
95
103
104
+ gThis = this ;
96
105
return (error == 0 );
97
106
}
98
107
99
108
#if __has_include ("lvgl.h")
109
+ #if (LVGL_VERSION_MAJOR == 9)
110
+ void _lvglTouchCb (lv_indev_t * indev, lv_indev_data_t * data) {
111
+ uint8_t contacts;
112
+ GDTpoint_t points[5 ];
113
+
114
+ contacts = gThis ->getTouchPoints (points);
115
+
116
+ if (contacts > 0 ) {
117
+ data->state = LV_INDEV_STATE_PRESSED;
118
+ data->point .x = points[0 ].x ;
119
+ data->point .y = points[0 ].y ;
120
+ } else {
121
+ data->state = LV_INDEV_STATE_RELEASED;
122
+ }
123
+
124
+ return ;
125
+ }
126
+ #else
100
127
void _lvglTouchCb (lv_indev_drv_t * indev, lv_indev_data_t * data) {
101
128
uint8_t contacts;
102
129
GDTpoint_t points[5 ];
@@ -114,6 +141,7 @@ void _lvglTouchCb(lv_indev_drv_t * indev, lv_indev_data_t * data) {
114
141
return ;
115
142
}
116
143
#endif
144
+ #endif
117
145
118
146
void Arduino_GigaDisplayTouch::end ()
119
147
{ }
0 commit comments