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

Revision:
41:e06e764ff4fd
Parent:
33:8a0a99d54bf8
--- a/Display/BiosTouch.cpp	Wed Jun 10 09:54:15 2015 +0000
+++ b/Display/BiosTouch.cpp	Wed Oct 23 06:59:29 2019 +0000
@@ -45,7 +45,7 @@
         void changeTouchInterrupt(bool enable, touch_irq_trigger_t trigger);
         TouchPanel::TouchError read(touch_coordinate_t* coord, int num);
         void run();
-        FunctionPointer* setListener(FunctionPointer* listener);
+        void setListener(Callback<void()> listener);
     private:
         Mail<touch_mail_t, NUM_MAILS> _mailbox;
         Mutex _mutex;
@@ -54,7 +54,7 @@
         bios_header_t* _bios;
         void* _biosData;
         int _points;
-        FunctionPointer* _listener;
+        Callback<void()> _listener;
         uint32_t _lostData;
         uint32_t _dbgAdded;
         uint32_t _dbgRemoved;
@@ -153,12 +153,9 @@
         log->printf("got non-mail event: 0x%x\n", evt.status);
         continue;
       }
-      _mutex.lock();
-      FunctionPointer* fp = _listener;
-      _mutex.unlock();
     
-      if (fp != NULL) {
-        fp->call();
+      if (_listener) {
+        _listener();
       }
     }
   } else {
@@ -174,12 +171,9 @@
         log->printf("got non-mail event: 0x%x\n", evt.status);
         continue;
       }
-      _mutex.lock();
-      FunctionPointer* fp = _listener;
-      _mutex.unlock();
   
-      if (fp != NULL) {
-        fp->call();
+      if (_listener) {
+        _listener();
       }
     }
   }
@@ -221,7 +215,7 @@
   switch (trigger) {
     case TOUCH_IRQ_RISING_EDGE:
       if (enable) {
-        _touchIRQ.rise(this, &TouchHandler::handleTouchInterrupt);
+        _touchIRQ.rise(callback(this, &TouchHandler::handleTouchInterrupt));
       } else {
         _touchIRQ.rise(NULL);
       }
@@ -229,7 +223,7 @@
 
     case TOUCH_IRQ_FALLING_EDGE:
       if (enable) {
-        _touchIRQ.fall(this, &TouchHandler::handleTouchInterrupt);
+        _touchIRQ.fall(callback(this, &TouchHandler::handleTouchInterrupt));
       } else {
         _touchIRQ.fall(NULL);
       }
@@ -243,13 +237,11 @@
   }
 }
 
-FunctionPointer* TouchHandler::setListener(FunctionPointer* listener)
+void TouchHandler::setListener(Callback<void()> listener)
 {
   _mutex.lock();
-  FunctionPointer* old = _listener;
   _listener = listener;
   _mutex.unlock();
-  return old;
 }
 
 
@@ -291,7 +283,8 @@
         break;
       }
 
-      _handlerThread = new Thread(touchTask, _handler);
+      _handlerThread = new Thread();
+      _handlerThread->start(callback(touchTask, _handler));
 
       _initialized = true;
     } while(0);
@@ -383,10 +376,9 @@
   return err;
 }
 
-FunctionPointer* BiosTouch::setListener(FunctionPointer* listener)
+void BiosTouch::setListener(Callback<void()> listener)
 {
   if (_initialized) {
-    return _handler->setListener(listener);
+    _handler->setListener(listener);
   }
-  return NULL;
 }