Skip to content

Commit 84f544e

Browse files
doc: update
1 parent a43957d commit 84f544e

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

docs/README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,33 @@ To use this library, you must have a supported Arduino board and the Arduino Gig
2121
```cpp
2222
#include "Arduino_GigaDisplayTouch.h"
2323

24-
Arduino_GigaDisplayTouch touch;
24+
Arduino_GigaDisplayTouch touchDetector;
2525

2626
void setup() {
27-
touch.begin();
27+
Serial.begin(115200);
28+
touchDetector.begin();
2829
}
2930

3031
void loop() {
3132
uint8_t contacts;
3233
GDTpoint_t points[5];
3334

34-
if(touch.detect(contacts, points)) {
35+
contacts = touchDetector.getTouchPoints(points);
36+
if (contacts > 0) { //Check if at least one touch occurs on the screen
37+
//Print the coordinates of all simultaneous contacts detected
38+
for (uint8_t i = 0; i < contacts; i++) {
39+
Serial.print(points[i].x);
40+
Serial.print(" ");
41+
Serial.println(points[i].y);
42+
}
3543
//Do something with the touch coordinates
3644
}
3745
}
3846
```
3947
## Examples
4048

41-
- **Touch_IRQ:** This example demonstrates how to detect touch event and retrieve coordinate values using the interrupt approach.
42-
- **Touch_Polling:** This example demonstrates how to detect touch event and retrieve coordinate values using the polling/on-request approach.
49+
- **[Touch_IRQ](../examples/Touch_IRQ):** This example demonstrates how to detect touch event and retrieve coordinate values using the interrupt approach.
50+
- **[Touch_Polling](../examples/Touch_Polling):** This example demonstrates how to detect touch event and retrieve coordinate values using the polling/on-request approach.
4351

4452
## API
4553

docs/api.md

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ The main class for managing the touch controller of the Giga Display Shield.
1414
`public ` [`Arduino_GigaDisplayTouch`](#)`(TwoWire& wire, uint8_t intPin, uint8_t rstPin, uint8_t addr)` | Construct a new touch controller for Giga Display Shield.
1515
`public bool` [`begin`](#)`()` | Initialize the touch controller.
1616
`public void` [`end`](#)`()` | De-initialize the touch controller.
17-
`public bool` [`detect`](#)`(uint8_t& contacts, GDTpoint_t* points)` | Check if a touch event is detected and get the touch points.
18-
`public void` [`attach`](#)`(void (*handler)(uint8_t, GDTpoint_t*))` | Attach an interrupt handler function for touch detection callbacks.
17+
`public uint8_t` [`getTouchPoints`](#)`(GDTpoint_t* points)` | Check if a touch event is detected and get the touch points.
18+
`public void` [`onDetect`](#)`(void (*handler)(uint8_t, GDTpoint_t*))` | Attach an interrupt handler function for touch detection callbacks.
1919

2020
## Members
2121

@@ -37,34 +37,25 @@ Construct a new touch controller for Giga Display Shield.
3737
Initialize the touch controller.
3838

3939
#### Returns
40-
true If the touch controller is successfully initialized
41-
42-
#### Returns
43-
false Otherwise
40+
true If the touch controller is successfully initialized, false otherwise
4441

4542
### `public void` [`end`](#)`()`
4643

4744
De-initialize the touch controller.
4845

49-
### `public bool` [`detect`](#)`(uint8_t& contacts, GDTpoint_t* points)`
46+
### `public uint8_t` [`getTouchPoints`](#)`(GDTpoint_t* points)`
5047

5148
Check if a touch event is detected and get the touch points.
5249

5350
#### Parameters
54-
* `contacts` The number of detected touch points.
55-
5651
* `points` The array containing the coordinates of the touch points.
5752

5853
#### Returns
59-
true If a touch event is detected
54+
uint8_t The number of detected touch points.
6055

61-
#### Returns
62-
false Otherwise
63-
64-
### `public void` [`attach`](#)`(void (*handler)(uint8_t, GDTpoint_t*))`
56+
### `public void` [`onDetect`](#)`(void (*handler)(uint8_t, GDTpoint_t*))`
6557

6658
Attach an interrupt handler function for touch detection callbacks.
6759

6860
#### Parameters
69-
7061
* `handler` The pointer to the user-defined handler function.

0 commit comments

Comments
 (0)