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:
- 33:8a0a99d54bf8
- Parent:
- 31:d47cffcb0a3e
diff -r fa8d2c7da38d -r 8a0a99d54bf8 Display/BiosTouch.cpp
--- a/Display/BiosTouch.cpp Thu Feb 19 12:23:04 2015 +0000
+++ b/Display/BiosTouch.cpp Thu Feb 19 14:41:14 2015 +0100
@@ -123,40 +123,64 @@
mbed_die();
}
memset(_latest, 0, _points*sizeof(touch_coordinate_t));
- while(true) {
- osEvent evt = _mailbox.get(osWaitForever);
- if (evt.status == osEventMail) {
- touch_mail_t* mail = (touch_mail_t*)evt.value.p;
- memcpy(_latest, mail->touch, mail->num * sizeof(touch_coordinate_t));
- _mailbox.free(mail);
- _dbgRemoved++;
- //if (_points == 1) {
- // log->printf("{%3d,%3d,%d} at %u/%u, with %u lost\n",
- // _latest[0].x,
- // _latest[0].y,
- // _latest[0].z,
- // _dbgRemoved, _dbgAdded,
- // _lostData);
- //} else {
- // log->printf("{%d,%d,%d,%d,%d} at %u/%u, with %u lost\n",
- // _latest[0].z,
- // _latest[1].z,
- // _latest[2].z,
- // _latest[3].z,
- // _latest[4].z,
- // _dbgRemoved, _dbgAdded,
- // _lostData);
- //}
- } else {
- log->printf("got non-mail event: 0x%x\n", evt.status);
- continue;
+ if (_points > 1) {
+ // multitouch - inject end event if missing
+ uint32_t maxDelay = osWaitForever;
+ while(true) {
+ osEvent evt = _mailbox.get(maxDelay);
+ if (evt.status == osEventMail) {
+ touch_mail_t* mail = (touch_mail_t*)evt.value.p;
+ memcpy(_latest, mail->touch, mail->num * sizeof(touch_coordinate_t));
+ _mailbox.free(mail);
+ _dbgRemoved++;
+ maxDelay = 25; // wait up to 25ms for next event before injecting a "pen up" event
+ } else if (evt.status == osEventTimeout) {
+ int numNonZero = 0;
+ for (int i = 0; i < _points; i++) {
+ if (_latest[i].z > 0) {
+ numNonZero++;
+ }
+ _latest[i].z = 0;
+ }
+ maxDelay = osWaitForever;
+ if (numNonZero == 0) {
+ // last event was a pen-up event so no need to inject one
+ //log->printf("skip penup\n");
+ continue;
+ }
+ //log->printf("inject penup\n");
+ } else {
+ log->printf("got non-mail event: 0x%x\n", evt.status);
+ continue;
+ }
+ _mutex.lock();
+ FunctionPointer* fp = _listener;
+ _mutex.unlock();
+
+ if (fp != NULL) {
+ fp->call();
+ }
}
- _mutex.lock();
- FunctionPointer* fp = _listener;
- _mutex.unlock();
-
- if (fp != NULL) {
- fp->call();
+ } else {
+ // normal singe-touch
+ while(true) {
+ osEvent evt = _mailbox.get(osWaitForever);
+ if (evt.status == osEventMail) {
+ touch_mail_t* mail = (touch_mail_t*)evt.value.p;
+ memcpy(_latest, mail->touch, mail->num * sizeof(touch_coordinate_t));
+ _mailbox.free(mail);
+ _dbgRemoved++;
+ } else {
+ log->printf("got non-mail event: 0x%x\n", evt.status);
+ continue;
+ }
+ _mutex.lock();
+ FunctionPointer* fp = _listener;
+ _mutex.unlock();
+
+ if (fp != NULL) {
+ fp->call();
+ }
}
}
}
