-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
The onDetect()
method can be used to attached interrupts so that when a touch event is detected by the GT911, the specified sub routine is ran specified by handler
in the function below.
Arduino_GigaDisplayTouch/src/Arduino_GigaDisplayTouch.cpp
Lines 173 to 177 in 4101b8a
void Arduino_GigaDisplayTouch::onDetect(void (*handler)(uint8_t, GDTpoint_t*)) { | |
_gt911TouchHandler = handler; | |
t.start(callback(&queue, &events::EventQueue::dispatch_forever)); | |
_irqInt.rise(queue.event(mbed::callback(this, &Arduino_GigaDisplayTouch::_gt911onIrq))); | |
} |
An example of how to use the interrupt is given in Touch_IRQ.ino
example.
touchDetector.onDetect(gigaTouchHandler); |
Arduino_GigaDisplayTouch/examples/Touch_IRQ/Touch_IRQ.ino
Lines 24 to 34 in 4101b8a
void gigaTouchHandler(uint8_t contacts, GDTpoint_t* points) { | |
Serial.print("Contacts: "); | |
Serial.println(contacts); | |
if (contacts > 0) { | |
/* First touch point */ | |
Serial.print(points[0].x); | |
Serial.print(" "); | |
Serial.println(points[0].y); | |
} | |
} |
It is not possible to detach the interrupt, using the current public methods. Detaching interrupts is useful for:
- Using
delay()
- Sending data over serial, without competing with the interrupt pin
Metadata
Metadata
Assignees
Labels
No labels