-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTouch_Polling.ino
54 lines (45 loc) · 1.53 KB
/
Touch_Polling.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Touch_Polling.ino
*
* This example shows how to get the number of points and the coordinates of the first touch points detected by the touch controller using polling.
*
* The setup() function initializes the serial communication and the touch controller. The loop() function continuously checks to see if a touch event is detected. Whenever a touch event is detcted, that prints the number of points and first touch co-ordinates to the Serial Monitor.
*
* For the interrupt version of this example, see Touch_IRQ.ino
*
* Instructions:
* 1. Connect your GIGA Display Shield (ASX00039) to a GIGA R1 WiFi (ABX00063) board .
* 2. Upload this sketch to your board.
* 3. Open the Serial Monitor.
* 4. Touch the screen with your finger(s) and view the coordinates printed on the Serial Monitor.
*
* Initial author: Leonardo Cavagnis @leonardocavagnis
* Created: 03 May 2023
*/
#include "Arduino_GigaDisplayTouch.h"
Arduino_GigaDisplayTouch touchDetector;
void setup() {
Serial.begin(115200);
while(!Serial) {}
if (touchDetector.begin()) {
Serial.print("Touch controller init - OK");
} else {
Serial.print("Touch controller init - FAILED");
while(1) ;
}
}
void loop() {
uint8_t contacts;
GDTpoint_t points[5];
contacts = touchDetector.getTouchPoints(points);
if (contacts > 0) {
Serial.print("Contacts: ");
Serial.println(contacts);
for (uint8_t i = 0; i < contacts; i++) {
Serial.print(points[i].x);
Serial.print(" ");
Serial.println(points[i].y);
}
}
delay(1);
}