Skip to content

Commit 12c710e

Browse files
add examples IRQ and Polling
1 parent f412e5d commit 12c710e

File tree

3 files changed

+77
-60
lines changed

3 files changed

+77
-60
lines changed

examples/GigaDisplay_touch/GigaDisplay_touch.ino

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

examples/Touch_IRQ/Touch_IRQ.ino

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Touch_IRQ
3+
4+
created 03 May 2023
5+
by Leonardo Cavagnis
6+
*/
7+
8+
#include "Arduino_GigaDisplayTouch.h"
9+
10+
Arduino_GigaDisplayTouch touch;
11+
12+
void gigaTouchHandler(uint8_t contacts, GDTpoint_t* points) {
13+
Serial.print("Contacts: ");
14+
Serial.println(contacts);
15+
16+
for (uint8_t i = 0; i < contacts; i++) {
17+
Serial.print(points[i].x);
18+
Serial.print(" ");
19+
Serial.println(points[i].y);
20+
}
21+
}
22+
23+
void setup() {
24+
Serial.begin(115200);
25+
while(!Serial) {}
26+
27+
if (touch.begin()) {
28+
Serial.println("Touch controller init - OK");
29+
} else {
30+
Serial.println("Touch controller init - FAILED");
31+
while(1) ;
32+
}
33+
34+
touch.attach(gigaTouchHandler);
35+
}
36+
37+
void loop() { }
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
Touch_Polling
3+
4+
created 03 May 2023
5+
by Leonardo Cavagnis
6+
*/
7+
8+
#include "Arduino_GigaDisplayTouch.h"
9+
10+
Arduino_GigaDisplayTouch touch;
11+
12+
void setup() {
13+
Serial.begin(115200);
14+
while(!Serial) {}
15+
16+
if (touch.begin()) {
17+
Serial.print("Touch controller init - OK");
18+
} else {
19+
Serial.print("Touch controller init - FAILED");
20+
while(1) ;
21+
}
22+
}
23+
24+
void loop() {
25+
uint8_t contacts;
26+
GDTpoint_t points[5];
27+
28+
if(touch.detect(contacts, points)) {
29+
Serial.print("Contacts: ");
30+
Serial.println(contacts);
31+
32+
for (uint8_t i = 0; i < contacts; i++) {
33+
Serial.print(points[i].x);
34+
Serial.print(" ");
35+
Serial.println(points[i].y);
36+
}
37+
}
38+
39+
delay(1);
40+
}

0 commit comments

Comments
 (0)