Skip to content

Commit 78489d8

Browse files
default constructor parameters for GIGA and PORTENTA boards
1 parent b55b510 commit 78489d8

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

examples/GigaDisplay_touch/GigaDisplay_touch.ino

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,10 @@
66
*/
77

88
#include "Arduino_GigaDisplayTouch.h"
9-
#include "pinDefinitions.h"
10-
11-
#define Wire Wire1
12-
#define INT_PIN PinNameToIndex(PI_1)
13-
#define RST_PIN PinNameToIndex(PI_2)
14-
#define WIRE_ADDR GT911_I2C_ADDR_BA_BB
159

1610
#define TOUCH_MODE 1 /* 1: Interrupt, 0: Polling */
1711

18-
Arduino_GigaDisplayTouch touch(Wire, INT_PIN, RST_PIN, WIRE_ADDR);
12+
Arduino_GigaDisplayTouch touch;
1913

2014
void gigaTouchHandler(uint8_t contacts, GDTpoint_t* points) {
2115
Serial.print("Contacts: ");
@@ -32,14 +26,10 @@ void setup() {
3226
Serial.begin(115200);
3327
while(!Serial) {}
3428

35-
Wire.setClock(400000); /* maximum transmission rate of 400K bps */
36-
Wire.begin();
37-
38-
Serial.print("Touch controller init ");
3929
if (touch.begin()) {
40-
Serial.println("SUCCESS");
30+
Serial.print("Touch controller init - OK");
4131
} else {
42-
Serial.println("FAILED");
32+
Serial.print("Touch controller init - FAILED");
4333
while(1) ;
4434
}
4535
#if TOUCH_MODE
@@ -54,7 +44,14 @@ void loop() {
5444
uint8_t contacts;
5545
GDTpoint_t points[5];
5646
if(touch.detect(contacts, points)) {
57-
Serial.println("Contacts!");
47+
Serial.print("Contacts: ");
48+
Serial.println(contacts);
49+
50+
for (uint8_t i = 0; i < contacts; i++) {
51+
Serial.print(points[i].x);
52+
Serial.print(" ");
53+
Serial.println(points[i].y);
54+
}
5855
}
5956
#endif
6057

src/Arduino_GigaDisplayTouch.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Arduino_GigaDisplayTouch::~Arduino_GigaDisplayTouch()
3030
{ }
3131

3232
bool Arduino_GigaDisplayTouch::begin() {
33+
_wire.setClock(400000); /* maximum transmission rate of 400K bps */
34+
_wire.begin();
35+
3336
delay(300);
3437

3538
/* GT911 Power-on timing procedure - Ref. pg10 GT911 Rev09 */

src/Arduino_GigaDisplayTouch.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/* Includes ------------------------------------------------------------------*/
1515
#include <Arduino.h>
1616
#include "Wire.h"
17+
#include "pinDefinitions.h"
1718

1819
/* Exported defines ----------------------------------------------------------*/
1920
#define GT911_I2C_ADDR_BA_BB (0x5D | 0x80) // 0xBA/0xBB - 0x5D (7bit address)
@@ -39,8 +40,20 @@ struct GDTpoint_s {
3940

4041
/* Class ----------------------------------------------------------------------*/
4142
class Arduino_GigaDisplayTouch {
42-
public:
43+
public:
44+
#if defined(ARDUINO_GIGA)
45+
Arduino_GigaDisplayTouch(TwoWire& wire = Wire1,
46+
uint8_t intPin = PinNameToIndex(PI_1),
47+
uint8_t rstPin = PinNameToIndex(PI_2),
48+
uint8_t addr = GT911_I2C_ADDR_BA_BB);
49+
#elif defined(ARDUINO_PORTENTA_H7_M7)
50+
Arduino_GigaDisplayTouch(TwoWire& wire = Wire,
51+
uint8_t intPin = PinNameToIndex(PD_4),
52+
uint8_t rstPin = PinNameToIndex(PD_5),
53+
uint8_t addr = GT911_I2C_ADDR_BA_BB);
54+
#else
4355
Arduino_GigaDisplayTouch(TwoWire& wire, uint8_t intPin, uint8_t rstPin, uint8_t addr);
56+
#endif
4457
~Arduino_GigaDisplayTouch();
4558

4659
bool begin();

0 commit comments

Comments
 (0)