Skip to content

Commit 717f8b1

Browse files
committed
Format library
1 parent a9bc96a commit 717f8b1

File tree

2 files changed

+265
-245
lines changed

2 files changed

+265
-245
lines changed

src/Arduino_GigaDisplayTouch.h

Lines changed: 76 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@
2121
* @author Leonardo Cavagnis
2222
* @brief Header file for the Arduino Giga Display Touch library.
2323
*
24-
* This library allows to capture up to 5 concurrent touch points on Arduino Giga Display Shield.
25-
* Supported controller: Goodix GT911
24+
* This library allows to capture up to 5 concurrent touch points on Arduino
25+
* Giga Display Shield. Supported controller: Goodix GT911
2626
*/
2727

2828
#ifndef __ARDUINO_GIGADISPLAYTOUCH_H
2929
#define __ARDUINO_GIGADISPLAYTOUCH_H
3030

3131
/* Includes ------------------------------------------------------------------*/
32-
#include <Arduino.h>
3332
#include "Wire.h"
3433
#include "mbed.h"
3534
#include "pinDefinitions.h"
35+
#include <Arduino.h>
3636

3737
/* Exported defines ----------------------------------------------------------*/
38-
#define GT911_I2C_ADDR_BA_BB (0x5D | 0x80) // 0xBA/0xBB - 0x5D (7bit address)
39-
#define GT911_I2C_ADDR_28_29 (0x14 | 0x80) // 0x28/0x29 - 0x14 (7bit address)
38+
#define GT911_I2C_ADDR_BA_BB (0x5D | 0x80) // 0xBA/0xBB - 0x5D (7bit address)
39+
#define GT911_I2C_ADDR_28_29 (0x14 | 0x80) // 0x28/0x29 - 0x14 (7bit address)
4040

41-
#define GT911_CONTACT_SIZE 8
42-
#define GT911_MAX_CONTACTS 5
41+
#define GT911_CONTACT_SIZE 8
42+
#define GT911_MAX_CONTACTS 5
4343

4444
/* Exported types ------------------------------------------------------------*/
4545
typedef struct GDTpoint_s GDTpoint_t;
@@ -52,87 +52,88 @@ typedef struct GDTpoint_s GDTpoint_t;
5252
* @brief Struct representing a touch point.
5353
*/
5454
struct GDTpoint_s {
55-
// 0x814F-0x8156, ... 0x8176 (5 points)
55+
// 0x814F-0x8156, ... 0x8176 (5 points)
5656
uint8_t trackId;
5757
uint16_t x;
5858
uint16_t y;
5959
uint16_t area;
6060
uint8_t reserved;
6161
};
6262

63-
/* Class ----------------------------------------------------------------------*/
63+
/* Class
64+
* ----------------------------------------------------------------------*/
6465

6566
/**
6667
* @class Arduino_GigaDisplayTouch
6768
* @brief Class for Giga Display Touch controller driver.
6869
*/
6970
class Arduino_GigaDisplayTouch {
70-
public:
71-
/**
72-
* @brief Construct a new touch controller for Giga Display Shield.
73-
*
74-
* @param wire A reference to the Wire interface to be used for communication with the touch controller.
75-
* @param intPin The interrupt pin number for the touch controller.
76-
* @param rstPin The reset pin number for the touch controller.
77-
* @param addr The device address for the touch controller.
78-
*/
79-
#if defined(ARDUINO_GIGA)
80-
Arduino_GigaDisplayTouch(TwoWire& wire = Wire1,
81-
uint8_t intPin = PinNameToIndex(PI_1),
82-
uint8_t rstPin = PinNameToIndex(PI_2),
83-
uint8_t addr = GT911_I2C_ADDR_BA_BB);
84-
#elif defined(ARDUINO_PORTENTA_H7_M7)
85-
Arduino_GigaDisplayTouch(TwoWire& wire = Wire,
86-
uint8_t intPin = PinNameToIndex(PD_4),
87-
uint8_t rstPin = PinNameToIndex(PD_5),
88-
uint8_t addr = GT911_I2C_ADDR_BA_BB);
89-
#else
90-
Arduino_GigaDisplayTouch(TwoWire& wire,
91-
uint8_t intPin,
92-
uint8_t rstPin,
93-
uint8_t addr);
94-
#endif
95-
~Arduino_GigaDisplayTouch();
96-
97-
98-
/**
99-
* @brief Initialize the touch controller.
100-
*
101-
* @return true If the touch controller is successfully initialized, false Otherwise
102-
*/
103-
bool begin();
104-
105-
/**
106-
* @brief De-initialize the touch controller.
107-
*/
108-
void end();
109-
110-
/**
111-
* @brief Check if a touch event is detected and get the touch points.
112-
* @param points The array containing the coordinates of the touch points.
113-
* @return uint8_t The number of detected touch points.
114-
*/
115-
uint8_t getTouchPoints(GDTpoint_t* points);
116-
117-
/**
118-
* @brief Attach an interrupt handler function for touch detection callbacks.
119-
* @param handler The pointer to the user-defined handler function.
120-
*/
121-
void onDetect(void (*handler)(uint8_t, GDTpoint_t*));
122-
private:
123-
TwoWire& _wire;
124-
uint8_t _intPin;
125-
mbed::InterruptIn _irqInt;
126-
uint8_t _rstPin;
127-
uint8_t _addr;
128-
GDTpoint_t _points[GT911_MAX_CONTACTS];
129-
void (*_gt911TouchHandler)(uint8_t, GDTpoint_t*);
130-
131-
uint8_t _gt911WriteOp(uint16_t reg, uint8_t data);
132-
uint8_t _gt911WriteBytesOp(uint16_t reg, uint8_t * data, uint8_t len);
133-
uint8_t _gt911ReadOp(uint16_t reg, uint8_t * data, uint8_t len);
134-
void _gt911onIrq();
135-
uint8_t _gt911ReadInputCoord(uint8_t * pointsbuf, uint8_t& contacts);
71+
public:
72+
/**
73+
* @brief Construct a new touch controller for Giga Display Shield.
74+
*
75+
* @param wire A reference to the Wire interface to be used for communication
76+
* with the touch controller.
77+
* @param intPin The interrupt pin number for the touch controller.
78+
* @param rstPin The reset pin number for the touch controller.
79+
* @param addr The device address for the touch controller.
80+
*/
81+
#if defined(ARDUINO_GIGA)
82+
Arduino_GigaDisplayTouch(TwoWire &wire = Wire1,
83+
uint8_t intPin = PinNameToIndex(PI_1),
84+
uint8_t rstPin = PinNameToIndex(PI_2),
85+
uint8_t addr = GT911_I2C_ADDR_BA_BB);
86+
#elif defined(ARDUINO_PORTENTA_H7_M7)
87+
Arduino_GigaDisplayTouch(TwoWire &wire = Wire,
88+
uint8_t intPin = PinNameToIndex(PD_4),
89+
uint8_t rstPin = PinNameToIndex(PD_5),
90+
uint8_t addr = GT911_I2C_ADDR_BA_BB);
91+
#else
92+
Arduino_GigaDisplayTouch(TwoWire &wire, uint8_t intPin, uint8_t rstPin,
93+
uint8_t addr);
94+
#endif
95+
~Arduino_GigaDisplayTouch();
96+
97+
/**
98+
* @brief Initialize the touch controller.
99+
*
100+
* @return true If the touch controller is successfully initialized, false
101+
* Otherwise
102+
*/
103+
bool begin();
104+
105+
/**
106+
* @brief De-initialize the touch controller.
107+
*/
108+
void end();
109+
110+
/**
111+
* @brief Check if a touch event is detected and get the touch points.
112+
* @param points The array containing the coordinates of the touch points.
113+
* @return uint8_t The number of detected touch points.
114+
*/
115+
uint8_t getTouchPoints(GDTpoint_t *points);
116+
117+
/**
118+
* @brief Attach an interrupt handler function for touch detection callbacks.
119+
* @param handler The pointer to the user-defined handler function.
120+
*/
121+
void onDetect(void (*handler)(uint8_t, GDTpoint_t *));
122+
123+
private:
124+
TwoWire &_wire;
125+
uint8_t _intPin;
126+
mbed::InterruptIn _irqInt;
127+
uint8_t _rstPin;
128+
uint8_t _addr;
129+
GDTpoint_t _points[GT911_MAX_CONTACTS];
130+
void (*_gt911TouchHandler)(uint8_t, GDTpoint_t *);
131+
132+
uint8_t _gt911WriteOp(uint16_t reg, uint8_t data);
133+
uint8_t _gt911WriteBytesOp(uint16_t reg, uint8_t *data, uint8_t len);
134+
uint8_t _gt911ReadOp(uint16_t reg, uint8_t *data, uint8_t len);
135+
void _gt911onIrq();
136+
uint8_t _gt911ReadInputCoord(uint8_t *pointsbuf, uint8_t &contacts);
136137
};
137138

138139
#endif /* __ARDUINO_GIGADISPLAYTOUCH_H */

0 commit comments

Comments
 (0)