Skip to content

Commit bdb2f2d

Browse files
Use Arduino_GigaDisplayTouch library in LVGLDemo example
1 parent c325482 commit bdb2f2d

File tree

5 files changed

+13
-108
lines changed

5 files changed

+13
-108
lines changed

libraries/Arduino_H7_Video/examples/LVGLDemo/LVGLDemo.ino

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,29 @@
77
*/
88

99
#include "Arduino_H7_Video.h"
10+
#include "Arduino_GigaDisplayTouch.h"
1011

1112
#include "lvgl.h"
12-
#include "giga_touch.h"
1313

14-
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
15-
//Arduino_H7_Video Display(1024, 768, USBCVideo);
16-
17-
void my_touchpad_read(lv_indev_drv_t * indev, lv_indev_data_t * data) {
18-
data->state = (touchpad_pressed) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
19-
if(data->state == LV_INDEV_STATE_PR) {
20-
data->point.x = giga_get_touch_x();
21-
data->point.y = giga_get_touch_y();
22-
touchpad_pressed = false;
14+
Arduino_H7_Video Display(800, 480, GigaDisplayShield); /* Arduino_H7_Video Display(1024, 768, USBCVideo); */
15+
Arduino_GigaDisplayTouch Touch;
2316

17+
void gigaTouchHandler(uint8_t contacts, GDTpoint_t* points) {
18+
if (contacts > 0) {
2419
Serial.print("Touch detected: ");
25-
Serial.print(data->point.x);
20+
Serial.print(points[0].x);
2621
Serial.print(",");
27-
Serial.println(data->point.y);
22+
Serial.println(points[0].y);
2823
}
29-
30-
return;
3124
}
3225

3326
void setup() {
3427
Serial.begin(115200);
35-
giga_touch_setup();
3628

3729
Display.begin();
38-
Display.attachLVGLTouchCb((void (*)(void*,void*))(my_touchpad_read));
39-
30+
Touch.begin();
31+
Touch.attach(gigaTouchHandler);
32+
4033
/* Change the active screen's background color */
4134
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x03989e), LV_PART_MAIN);
4235

@@ -48,9 +41,6 @@ void setup() {
4841
}
4942

5043
void loop() {
51-
/* Touch handler */
52-
giga_touch_handler();
53-
5444
/* Feed LVGL engine */
5545
lv_timer_handler();
5646
}

libraries/Arduino_H7_Video/examples/LVGLDemo/giga_touch.cpp

Lines changed: 0 additions & 78 deletions
This file was deleted.

libraries/Arduino_H7_Video/examples/LVGLDemo/giga_touch.h

Lines changed: 0 additions & 7 deletions
This file was deleted.

libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Arduino_H7_Video::~Arduino_H7_Video() {
5151

5252
int Arduino_H7_Video::begin() {
5353
if (!ArduinoGraphics::begin()) {
54-
return 0;
54+
return H7V_ERR_UNKNOWN;
5555
}
5656

5757
textFont(Font_5x7);
@@ -93,7 +93,7 @@ int Arduino_H7_Video::begin() {
9393
lv_disp_drv_register(&disp_drv); /* Finally register the driver */
9494
#endif
9595

96-
return H7V_OK;
96+
return 0;
9797
}
9898

9999
void Arduino_H7_Video::end() {

libraries/Arduino_H7_Video/src/Arduino_H7_Video.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "H7DisplayShield.h"
1717

1818
/* Exported defines ----------------------------------------------------------*/
19-
#define H7V_OK 1
19+
#define H7V_ERR_UNKNOWN 1
2020
#define H7V_ERR_INSUFFMEM 2
2121

2222
/* Exported enumeration ------------------------------------------------------*/

0 commit comments

Comments
 (0)