Skip to content

Commit e1a53e2

Browse files
committed
feat: add MultiTouch Polling example
1 parent ab78f0e commit e1a53e2

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* MultiTouchBlink_Polling.ino
3+
*
4+
* This example shows how to visualise the number of touch points, using the RGB LED.
5+
*
6+
* On each iteration of the loop, the touch points are obtained from the GT911 controller. If the touch points exist, then a message
7+
* is sent to the Serial, and the LED is blinked the corresponding number of times. A 1 second delay is given after a touch is detected, to
8+
* act as a basic debounce utility.
9+
*
10+
* For the interrupt version of this example, see MultiTouchBlink_IRQ.ino
11+
*
12+
* Instructions:
13+
* 1. Connect your GIGA Display Shield (ASX00039) to a GIGA R1 WiFi (ABX00063) board.
14+
* 2. Upload this sketch to your board.
15+
* 3. Open the Serial Monitor.
16+
* 4. Touch the screen with your finger(s).
17+
* 5. The LED will blink, based on how many touch contact are recorded. Note that fingers need to be placed all at the same time.
18+
*
19+
* Initial author: Ali Jahangiri @aliphys
20+
* Created: 12 June 2024
21+
*/
22+
23+
#include "Arduino_GigaDisplayTouch.h"
24+
25+
Arduino_GigaDisplayTouch touchDetector;
26+
27+
int contactPoints = 0;
28+
29+
void setup() {
30+
Serial.begin(115200);
31+
while (!Serial) {}
32+
33+
if (touchDetector.begin()) {
34+
Serial.println("Touch controller init - OK");
35+
} else {
36+
Serial.println("Touch controller init - FAILED");
37+
while (1)
38+
;
39+
}
40+
}
41+
42+
void loop() {
43+
uint8_t contacts;
44+
GDTpoint_t points[5];
45+
contactPoints = 0;
46+
47+
contactPoints = touchDetector.getTouchPoints(points);
48+
49+
if (contactPoints > 0) {
50+
Serial.println("Contact Detected! Will Blink " + String(contactPoints) + " times!");
51+
for (int i = 1; i <= contactPoints; i++) {
52+
digitalWrite(LED_BUILTIN, LOW);
53+
delay(250);
54+
digitalWrite(LED_BUILTIN, HIGH);
55+
delay(250);
56+
}
57+
58+
delay(1000);
59+
}
60+
61+
delay(1);
62+
}

0 commit comments

Comments
 (0)