1+ /*
2+ * Copyright 2023 Arduino SA
3+ *
4+ * This program is free software: you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation, either version 3 of the License, or
7+ * (at your option) any later version.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU Lesser General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU Lesser General Public License
15+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16+ *
17+ */
18+
119/* *
2- ******************************************************************************
3- * @file Arduino_GigaDisplayTouch.h
4- * @author Leonardo Cavagnis
5- * @version
6- * @date
7- * @brief
8- ******************************************************************************
9- */
10-
11- #ifndef _ARDUINO_GIGADISPLAYTOUCH_H
12- #define _ARDUINO_GIGADISPLAYTOUCH_H
20+ * @file Arduino_GigaDisplayTouch.h
21+ * @author Leonardo Cavagnis
22+ * @brief Header file for the Arduino Giga Display Touch library.
23+ *
24+ * This library allows to capture up to 5 concurrent touch points on Arduino Giga Display Shield.
25+ * Supported controller: Goodix GT911
26+ */
27+
28+ #ifndef __ARDUINO_GIGADISPLAYTOUCH_H
29+ #define __ARDUINO_GIGADISPLAYTOUCH_H
1330
1431/* Includes ------------------------------------------------------------------*/
1532#include < Arduino.h>
@@ -40,8 +57,21 @@ struct GDTpoint_s {
4057};
4158
4259/* Class ----------------------------------------------------------------------*/
60+
61+ /* *
62+ * @class Arduino_GigaDisplayTouch
63+ * @brief Class for Giga Display Touch controller driver.
64+ */
4365class Arduino_GigaDisplayTouch {
4466 public:
67+ /* *
68+ * @brief Construct a new touch controller for Giga Display Shield.
69+ *
70+ * @param wire A reference to the Wire interface to be used for communication with the touch controller.
71+ * @param intPin The interrupt pin number for the touch controller.
72+ * @param rstPin The reset pin number for the touch controller.
73+ * @param addr The device address for the touch controller.
74+ */
4575 #if defined(ARDUINO_GIGA)
4676 Arduino_GigaDisplayTouch (TwoWire& wire = Wire1,
4777 uint8_t intPin = PinNameToIndex(PI_1),
@@ -60,10 +90,33 @@ class Arduino_GigaDisplayTouch {
6090 #endif
6191 ~Arduino_GigaDisplayTouch ();
6292
93+
94+ /* *
95+ * @brief Initialize the touch controller.
96+ *
97+ * @return true If the controller is correctly configured
98+ * @return false Otherwise
99+ */
63100 bool begin ();
101+
102+ /* *
103+ * @brief De-initialize the touch controller.
104+ */
64105 void end ();
65106
107+ /* *
108+ * @brief Check if a touch event is detected and get the touch points.
109+ * @param contacts The number of detected touch points.
110+ * @param points The array containing the coordinates of the touch points.
111+ * @return true If a touch event is detected
112+ * @return false Otherwise
113+ */
66114 bool detect (uint8_t & contacts, GDTpoint_t* points);
115+
116+ /* *
117+ * @brief Attach an interrupt handler function for touch detection callbacks.
118+ * @param handler The pointer to the user-defined handler function.
119+ */
67120 void attach (void (*handler)(uint8_t , GDTpoint_t*));
68121 private:
69122 TwoWire& _wire;
@@ -81,4 +134,4 @@ class Arduino_GigaDisplayTouch {
81134 uint8_t _gt911ReadInputCoord (uint8_t * pointsbuf, uint8_t & contacts);
82135};
83136
84- #endif /* _ARDUINO_GIGADISPLAYTOUCH_H */
137+ #endif /* __ARDUINO_GIGADISPLAYTOUCH_H */
0 commit comments