1
+ /*
2
+ * MultiTouchBlink_IRQ.ino
3
+ *
4
+ * This example shows how to visualise the number of touch points, using the RGB LED.
5
+ *
6
+ * Whenever a touch event is detected, gigaTouchHandler() records the number of touches and blinks the RGB LED accordingly.
7
+ * The event is also detected and sent via Serial. The touch handler is detached, blink is performed and then re-attached.
8
+ *
9
+ * For the polling version of this example, see MultiTouchBlink_IRQ.ino
10
+ *
11
+ * Instructions:
12
+ * 1. Connect your GIGA Display Shield (ASX00039) to a GIGA R1 WiFi (ABX00063) board.
13
+ * 2. Upload this sketch to your board.
14
+ * 3. Open the Serial Monitor.
15
+ * 4. Touch the screen with your finger(s).
16
+ * 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.
17
+ *
18
+ * Initial author: Ali Jahangiri @aliphys
19
+ * Created: 12 June 2024
20
+ */
21
+
22
+ #include " Arduino_GigaDisplayTouch.h"
23
+
24
+ Arduino_GigaDisplayTouch touchDetector;
25
+
26
+ int contactPoints = 0 ;
27
+
28
+ void gigaTouchHandler (uint8_t contacts, GDTpoint_t* points) {
29
+ contactPoints = contacts;
30
+ touchDetector.end (); // close the touch controller
31
+ }
32
+
33
+ void setup () {
34
+ Serial.begin (115200 );
35
+ while (!Serial) {}
36
+
37
+ if (touchDetector.begin ()) {
38
+ Serial.println (" Touch controller init - OK" );
39
+ } else {
40
+ Serial.println (" Touch controller init - FAILED" );
41
+ while (1 );
42
+ }
43
+
44
+ touchDetector.onDetect (gigaTouchHandler);
45
+ }
46
+
47
+ void loop () {
48
+ if (contactPoints > 0 ) {
49
+ Serial.println (" Contact Detected! Will Blink " + String (contactPoints) + " times!" );
50
+ for (int i = 0 ; i < contactPoints; i++) {
51
+ digitalWrite (LED_BUILTIN, LOW);
52
+ delay (250 );
53
+ digitalWrite (LED_BUILTIN, HIGH);
54
+ delay (250 );
55
+ }
56
+ contactPoints = 0 ;
57
+ touchDetector.begin ();
58
+ delay (100 );
59
+ touchDetector.onDetect (gigaTouchHandler);
60
+ }
61
+ }
0 commit comments