Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DM_FATFileSystem EthernetInterface HTTPClient mbed-rtos mbed-src
Fork of DMSupport by
Diff: Display/BiosTouch.cpp
- Revision:
- 24:9a677afc86f1
- Parent:
- 23:6afd6a716e80
- Child:
- 26:a65fbb4bde5c
diff -r 6afd6a716e80 -r 9a677afc86f1 Display/BiosTouch.cpp
--- a/Display/BiosTouch.cpp Fri Jan 16 11:15:57 2015 +0100
+++ b/Display/BiosTouch.cpp Sat Jan 17 14:12:37 2015 +0100
@@ -89,13 +89,13 @@
static void touchIrqEnabler(uint32_t arg, bool enable, bool rising)
{
((TouchHandler*)arg)->changeTouchInterrupt(enable, rising);
-#if defined(DM_BOARD_ENABLE_MEASSURING_PINS)
- if (enable) {
- SET_MEAS_PIN_1();
- } else {
- CLR_MEAS_PIN_1();
- }
-#endif
+//#if defined(DM_BOARD_ENABLE_MEASSURING_PINS)
+// if (enable) {
+// SET_MEAS_PIN_1();
+// } else {
+// CLR_MEAS_PIN_1();
+// }
+//#endif
}
static void touchTask(void const* args)
@@ -115,7 +115,46 @@
mbed_die();
}
memset(_latest, 0, _points*sizeof(touch_coordinate_t));
+ uint32_t maxDelay = osWaitForever;
+SET_MEAS_PIN_1();
while(true) {
+#if 1
+ osEvent evt = Thread::signal_wait(SIG_NEW_DATA, maxDelay);
+ if (evt.status == osEventTimeout) {
+ // got a timeout after the last touch event, now go back to
+ // waiting forever for the next one
+ maxDelay = osWaitForever;
+SET_MEAS_PIN_1();
+ } else {
+ // normal event, start a timeout to make sure that we get an
+ // event when the user stops fiddling with the display
+ //maxDelay = 10;
+CLR_MEAS_PIN_1();
+ }
+SET_MEAS_PIN_3();
+ _bios->touchIrqHandler(_biosData);
+CLR_MEAS_PIN_3();
+
+ _mutex.lock();
+ err = _bios->touchRead(_biosData, _latest, _points);
+ FunctionPointer* fp = _listener;
+ _mutex.unlock();
+
+ if (err == BiosError_Ok) {
+ //notify registered callbacks
+ if (fp != NULL) {
+SET_MEAS_PIN_4();
+ fp->call();
+CLR_MEAS_PIN_4();
+ }
+ } else {
+ log->printf("Failed to read touch event, err = %d\n", err);
+ }
+
+ // mode 2 - wait max 10ms for touch event and simulate
+ // one if there isn't anyone (for the "touch up"
+ // event)
+#else
Thread::signal_wait(SIG_NEW_DATA);
// if (_haveData) {
// _haveData = false;
@@ -132,12 +171,13 @@
if (fp != NULL) {
SET_MEAS_PIN_4();
fp->call();
- SET_MEAS_PIN_4();
+ CLR_MEAS_PIN_4();
}
} else {
log->printf("Failed to read touch event, err = %d\n", err);
}
// }
+#endif
}
//if (_latest != NULL) {
// free(_latest);
