1616#define GT911_REG_CONFIG_VERSION 0x8047
1717
1818/* Private variables ---------------------------------------------------------*/
19- volatile bool _gt911DataReadyIrq = false ;
19+ rtos::Thread t;
20+ events::EventQueue queue (32 * EVENTS_EVENT_SIZE);
2021
2122/* Private function prototypes -----------------------------------------------*/
2223void _gt911_irqHandler ();
2324
2425/* Functions -----------------------------------------------------------------*/
2526Arduino_GigaDisplayTouch::Arduino_GigaDisplayTouch (TwoWire& wire, uint8_t intPin, uint8_t rstPin, uint8_t addr)
26- : _wire{wire}, _intPin{intPin}, _rstPin{rstPin}, _addr{addr}
27+ : _wire{wire}, _intPin{intPin}, _rstPin{rstPin}, _addr{addr}, _irqInt{ digitalPinToPinName (intPin)}
2728{ }
2829
2930Arduino_GigaDisplayTouch::~Arduino_GigaDisplayTouch ()
@@ -55,7 +56,6 @@ bool Arduino_GigaDisplayTouch::begin() {
5556 delay (51 );
5657 pinMode (_intPin, INPUT);
5758
58- _gt911DataReadyIrq = false ;
5959 _gt911TouchHandler = nullptr ;
6060
6161 /* GT911 test communication */
@@ -68,13 +68,6 @@ bool Arduino_GigaDisplayTouch::begin() {
6868void Arduino_GigaDisplayTouch::end ()
6969{ }
7070
71- void Arduino_GigaDisplayTouch::detect () {
72- if (_gt911DataReadyIrq) {
73- _gt911onIrq ();
74- _gt911DataReadyIrq = false ;
75- }
76- }
77-
7871bool Arduino_GigaDisplayTouch::detect (uint8_t & contacts, GDTpoint_t* points) {
7972 uint8_t rawpoints[GT911_MAX_CONTACTS * GT911_CONTACT_SIZE];
8073 uint8_t error;
@@ -99,7 +92,9 @@ bool Arduino_GigaDisplayTouch::detect(uint8_t& contacts, GDTpoint_t* points) {
9992}
10093
10194void Arduino_GigaDisplayTouch::attach (void (*handler)(uint8_t , GDTpoint_t*)) {
102- attachInterrupt (_intPin, _gt911_irqHandler, RISING);
95+ t.start (callback (&queue, &events::EventQueue::dispatch_forever));
96+ _irqInt.rise (queue.event (mbed::callback (this , &Arduino_GigaDisplayTouch::_gt911onIrq)));
97+
10398 _gt911TouchHandler = handler;
10499}
105100
@@ -186,10 +181,4 @@ uint8_t Arduino_GigaDisplayTouch::_gt911ReadInputCoord(uint8_t * pointsbuf, uint
186181 return 0 ;
187182}
188183
189- void _gt911_irqHandler () {
190- noInterrupts ();
191- _gt911DataReadyIrq = true ;
192- interrupts ();
193- }
194-
195184/* *** END OF FILE ****/
0 commit comments