![](/media/cache/group/logo.png.50x50_q85.jpg)
A board support package for the LPC4088 Display Module.
Dependencies: DM_HttpServer DM_USBHost
Dependents: lpc4088_displaymodule_emwin lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI ... more
Fork of DMSupport by
Diff: Display/BiosTouch.cpp
- Revision:
- 33:8a0a99d54bf8
- Parent:
- 31:d47cffcb0a3e
- Child:
- 41:e06e764ff4fd
--- 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(); + } } } }