-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMultiTouchBlink_IRQ.ino
61 lines (53 loc) · 1.77 KB
/
MultiTouchBlink_IRQ.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
55
56
57
58
59
60
61
/*
* MultiTouchBlink_IRQ.ino
*
* This example shows how to visualise the number of touch points, using the RGB LED.
*
* Whenever a touch event is detected, gigaTouchHandler() records the number of touches and blinks the RGB LED accordingly.
* The event is also detected and sent via Serial. The touch handler is detached, blink is performed and then re-attached.
*
* For the polling version of this example, see MultiTouchBlink_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).
* 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.
*
* Initial author: Ali Jahangiri @aliphys
* Created: 12 June 2024
*/
#include "Arduino_GigaDisplayTouch.h"
Arduino_GigaDisplayTouch touchDetector;
int contactPoints = 0;
void gigaTouchHandler(uint8_t contacts, GDTpoint_t* points) {
contactPoints = contacts;
touchDetector.end(); // close the touch controller
}
void setup() {
Serial.begin(115200);
while (!Serial) {}
if (touchDetector.begin()) {
Serial.println("Touch controller init - OK");
} else {
Serial.println("Touch controller init - FAILED");
while (1);
}
touchDetector.onDetect(gigaTouchHandler);
}
void loop() {
if (contactPoints > 0) {
Serial.println("Contact Detected! Will Blink " + String(contactPoints) + " times!");
for (int i = 0; i < contactPoints; i++) {
digitalWrite(LED_BUILTIN, LOW);
delay(250);
digitalWrite(LED_BUILTIN, HIGH);
delay(250);
}
contactPoints = 0;
touchDetector.begin();
delay(100);
touchDetector.onDetect(gigaTouchHandler);
}
}