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 EmbeddedArtists AB

Files at this revision

API Documentation at this revision

Comitter:
embeddedartists
Date:
Thu Feb 19 14:41:14 2015 +0100
Parent:
32:fa8d2c7da38d
Child:
34:fc366bab393f
Commit message:
- Added special treatement of touch controller for multitouch
- Corrected button pin name (wrong after switching to LPC4088_DM as target
- Fixed bug in QSPIFileSystem that prevented opening the root folder

Changed in this revision

DMBoard.cpp Show annotated file Show diff for this revision Revisions of this file
Display/BiosTouch.cpp Show annotated file Show diff for this revision Revisions of this file
FileSystems/QSPIFileSystem.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/DMBoard.cpp	Thu Feb 19 12:23:04 2015 +0000
+++ b/DMBoard.cpp	Thu Feb 19 14:41:14 2015 +0100
@@ -76,7 +76,7 @@
     _qspifs("qspi"),
 #endif
     _buzzer(P1_5),
-    _button(p23),
+    _button(P2_10),
     _led1(LED1),
     _led2(LED2),
     _led3(LED3),
--- 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();
+      }
     }
   }
 }
--- a/FileSystems/QSPIFileSystem.cpp	Thu Feb 19 12:23:04 2015 +0000
+++ b/FileSystems/QSPIFileSystem.cpp	Thu Feb 19 14:41:14 2015 +0100
@@ -1405,6 +1405,11 @@
 DirHandle *QSPIFileSystem::opendir(const char *name)
 {
   if (isformatted()) {
+    if (*name == '\0') {
+        // opendir("/qspi/") will result in a call to this function with name=""
+        return QSPIDirHandle::openDir(name);
+    }
+    
     FileHandle* fh = open(name, O_RDONLY);
     if (fh != NULL) {
       // Attempting to open a file as a dir