Example using the support package for LPC4088 DisplayModule

Dependencies:   DMBasicGUI DMSupport

Example using a lot of the features in the software package for the LPC4088 Display Module.

This project can be selected as a template when creating a new project based on the LPC4088 Display Module.

Information

This project works on the 4.3" display modules.

Some of the apps works on the 5" display modules. The ImageViewer and Slideshow app will show the images distorted as it does not take the resolution into consideration.

Information

The USB Status app is disabled. The Image viewer looks for images in the root of SD cards, USB memory sticks or the file system on the QSPI flash. The Slideshow app expects to find a slideshow script in /mci/elec14/ea_logo.txt.

This is what it looks like on the 4.3" display:

/media/uploads/embeddedartists/everything_cap_000.png /media/uploads/embeddedartists/everything_cap_001.png /media/uploads/embeddedartists/everything_cap_003.png /media/uploads/embeddedartists/everything_cap_004.png /media/uploads/embeddedartists/everything_cap_006.png /media/uploads/embeddedartists/everything_cap_008.png

Files at this revision

API Documentation at this revision

Comitter:
embeddedartists
Date:
Mon Nov 04 14:33:29 2019 +0000
Parent:
29:be8b784873f5
Commit message:
More updates related to mbed OS 5

Changed in this revision

AppDraw.cpp Show annotated file Show diff for this revision Revisions of this file
AppImageViewer.cpp Show annotated file Show diff for this revision Revisions of this file
AppNetworkSettings.cpp Show annotated file Show diff for this revision Revisions of this file
AppRTCSettings.cpp Show annotated file Show diff for this revision Revisions of this file
AppStatus.cpp Show annotated file Show diff for this revision Revisions of this file
AppUSBMouse.cpp Show annotated file Show diff for this revision Revisions of this file
DMBasicGUI.lib Show annotated file Show diff for this revision Revisions of this file
DMSupport.lib Show annotated file Show diff for this revision Revisions of this file
dm_board_config.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r be8b784873f5 -r e1cded731965 AppDraw.cpp
--- a/AppDraw.cpp	Tue Apr 28 11:49:03 2015 +0000
+++ b/AppDraw.cpp	Mon Nov 04 14:33:29 2019 +0000
@@ -112,7 +112,7 @@
     while(!done) {
       // wait for a new touch signal (signal is sent from AppLauncher,
       // which listens for touch events)
-      Thread::signal_wait(0x1);
+      ThisThread::flags_wait_all(0x1);
       if (touch->read(_coords, fingers) == TouchPanel::TouchError_Ok) {
         for (int i = 0; i < fingers; i++) {
           if (_coords[i].z > 0) {
diff -r be8b784873f5 -r e1cded731965 AppImageViewer.cpp
--- a/AppImageViewer.cpp	Tue Apr 28 11:49:03 2015 +0000
+++ b/AppImageViewer.cpp	Mon Nov 04 14:33:29 2019 +0000
@@ -173,7 +173,8 @@
 
     _active = 1;
     
-    Thread* tLoader = new Thread(loaderTask, this, osPriorityNormal, 8192);
+    Thread* tLoader = new Thread(osPriorityNormal, 8192);
+    tLoader->start(callback(loaderTask, this));
     
     bool first = true;
     Timer t;
@@ -202,13 +203,13 @@
           t.start();
         } else {
           while (t.read_ms() < 2000) {
-            Thread::wait(100);
+            ThisThread::sleep_for(100);
           }
         }
         _disp->setFramebuffer(fb);
         _active = (_active == 1 ? 2 : 1);
         t.reset();
-      } else if (tLoader->get_state() == Thread::Inactive) {
+      } else if (tLoader->get_state() == Thread::Deleted) {
         // No more images in the queue and the loader thread 
         // has completed its search
         break;
@@ -227,7 +228,7 @@
     TouchPanel* touch = DMBoard::instance().touchPanel();
     touch_coordinate_t coord;
     while(!done) {
-      Thread::signal_wait(0x1);
+      ThisThread::flags_wait_all(0x1);
       if (touch->read(coord) == TouchPanel::TouchError_Ok) {
         if (_btn->handle(coord.x, coord.y, coord.z > 0)) {
             _btn->draw();
diff -r be8b784873f5 -r e1cded731965 AppNetworkSettings.cpp
--- a/AppNetworkSettings.cpp	Tue Apr 28 11:49:03 2015 +0000
+++ b/AppNetworkSettings.cpp	Mon Nov 04 14:33:29 2019 +0000
@@ -272,7 +272,7 @@
 
     uint32_t maxDelay = osWaitForever; 
     while(!done && !abort) {
-      Thread::signal_wait(0x1, maxDelay);
+      ThisThread::flags_wait_all(0x1, maxDelay);
       if (touch->read(coord) == TouchPanel::TouchError_Ok) {
         for (int i = 0; i < NumButtons; i++) {
           if (_buttons[i]->handle(coord.x, coord.y, coord.z > 0)) {
@@ -301,13 +301,13 @@
       Registry* reg = DMBoard::instance().registry();
       RtosLog* log = DMBoard::instance().logger();
       char buf[16] = {0};
-      sprintf(buf, "%lu.%lu.%lu.%lu", _values[0], _values[1], _values[2], _values[3]);
+      sprintf(buf, "%u.%u.%u.%u", _values[0], _values[1], _values[2], _values[3]);
       reg->setValue("IP Address", buf);
       log->printf("New STATIC IP Address: %s\n", buf);
-      sprintf(buf, "%lu.%lu.%lu.%lu", _values[4], _values[5], _values[6], _values[7]);
+      sprintf(buf, "%u.%u.%u.%u", _values[4], _values[5], _values[6], _values[7]);
       reg->setValue("Net Mask", buf);
       log->printf("New STATIC Net Mask:   %s\n", buf);
-      sprintf(buf, "%lu.%lu.%lu.%lu", _values[8], _values[9], _values[10], _values[11]);
+      sprintf(buf, "%u.%u.%u.%u", _values[8], _values[9], _values[10], _values[11]);
       reg->setValue("Gateway", buf);
       log->printf("New STATIC Gateway:    %s\n", buf);
       reg->store();
diff -r be8b784873f5 -r e1cded731965 AppRTCSettings.cpp
--- a/AppRTCSettings.cpp	Tue Apr 28 11:49:03 2015 +0000
+++ b/AppRTCSettings.cpp	Mon Nov 04 14:33:29 2019 +0000
@@ -306,7 +306,7 @@
 
     uint32_t maxDelay = osWaitForever; 
     while(!done && !abort) {
-      Thread::signal_wait(0x1, maxDelay);
+      ThisThread::flags_wait_all(0x1, maxDelay);
       if (touch->read(coord) == TouchPanel::TouchError_Ok) {
         for (int i = 0; i < NumButtons; i++) {
           if (_buttons[i]->handle(coord.x, coord.y, coord.z > 0)) {
diff -r be8b784873f5 -r e1cded731965 AppStatus.cpp
--- a/AppStatus.cpp	Tue Apr 28 11:49:03 2015 +0000
+++ b/AppStatus.cpp	Mon Nov 04 14:33:29 2019 +0000
@@ -80,10 +80,10 @@
     // Column 2
 #if defined(DM_BOARD_USE_ETHERNET)
     if (ethInitialized) {
-        swim_put_text_xy(_win, eth.getIPAddress(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 1);
-        swim_put_text_xy(_win, eth.getNetworkMask(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 2);
-        swim_put_text_xy(_win, eth.getGateway(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 3);    
-        swim_put_text_xy(_win, eth.getMACAddress(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 4);
+        swim_put_text_xy(_win, eth.get_ip_address(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 1);
+        swim_put_text_xy(_win, eth.get_netmask(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 2);
+        swim_put_text_xy(_win, eth.get_gateway(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 3);    
+        swim_put_text_xy(_win, eth.get_mac_address(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 4);
         swim_put_text_xy(_win, ethUsingDHCP?"DHCP":"Static IP", ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 5);
     } else {
 #else
@@ -166,7 +166,7 @@
     TouchPanel* touch = DMBoard::instance().touchPanel();
     touch_coordinate_t coord;
     while(!done) {
-      Thread::signal_wait(0x1);
+      ThisThread::flags_wait_all(0x1);
       if (touch->read(coord) == TouchPanel::TouchError_Ok) {
         if (_btn->handle(coord.x, coord.y, coord.z > 0)) {
             _btn->draw();
diff -r be8b784873f5 -r e1cded731965 AppUSBMouse.cpp
--- a/AppUSBMouse.cpp	Tue Apr 28 11:49:03 2015 +0000
+++ b/AppUSBMouse.cpp	Mon Nov 04 14:33:29 2019 +0000
@@ -73,6 +73,7 @@
 void AppUSBMouse::runToCompletion()
 {
     bool done = false;
+    uint32_t flags = 0;
     draw();
     void* oldFB = _disp->swapFramebuffer(_fb);
     
@@ -89,8 +90,8 @@
     while(!done) {
       // wait for a new touch signal (signal is sent from AppLauncher,
       // which listens for touch events)
-      osEvent evt = Thread::signal_wait(0x1, 50);
-      if (evt.status == osEventTimeout) {
+      flags = ThisThread::flags_wait_all_for(0x1, 50);
+      if (flags == 0) {
         if (board->buttonPressed()) {
           done = true;
         }
diff -r be8b784873f5 -r e1cded731965 DMBasicGUI.lib
--- a/DMBasicGUI.lib	Tue Apr 28 11:49:03 2015 +0000
+++ b/DMBasicGUI.lib	Mon Nov 04 14:33:29 2019 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Embedded-Artists/code/DMBasicGUI/#1a7c743600e6
+http://developer.mbed.org/teams/Embedded-Artists/code/DMBasicGUI/#f0d00f29bfeb
diff -r be8b784873f5 -r e1cded731965 DMSupport.lib
--- a/DMSupport.lib	Tue Apr 28 11:49:03 2015 +0000
+++ b/DMSupport.lib	Mon Nov 04 14:33:29 2019 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Embedded-Artists/code/DMSupport/#e1cb4dd9bfeb
+http://developer.mbed.org/teams/Embedded-Artists/code/DMSupport/#bbfe299d4a0c
diff -r be8b784873f5 -r e1cded731965 dm_board_config.h
--- a/dm_board_config.h	Tue Apr 28 11:49:03 2015 +0000
+++ b/dm_board_config.h	Mon Nov 04 14:33:29 2019 +0000
@@ -27,7 +27,7 @@
 // #define DM_BOARD_USE_QSPI
 #define DM_BOARD_USE_DISPLAY
 #define DM_BOARD_USE_TOUCH
-// #define DM_BOARD_USE_ETHERNET
+//#define DM_BOARD_USE_ETHERNET
 #define DM_BOARD_USE_FAST_UART
 // #define DM_BOARD_USE_USBSERIAL_IN_RTOSLOG
 // #define DM_BOARD_DISABLE_STANDARD_PRINTF
diff -r be8b784873f5 -r e1cded731965 main.cpp
--- a/main.cpp	Tue Apr 28 11:49:03 2015 +0000
+++ b/main.cpp	Mon Nov 04 14:33:29 2019 +0000
@@ -11,7 +11,6 @@
 #if defined(DM_BOARD_USE_ETHERNET)
   #include "EthernetInterface.h"
   #include "HTTPServer.h"
-  #include "mbed_rpc.h"
 #endif
 #if defined(DM_BOARD_USE_USB_DEVICE)
   #include "USBMSD_RAMFS.h"
@@ -79,7 +78,7 @@
  * Local functions
  *****************************************************************************/
 
-void aliveTask(void const* args)
+void aliveTask(void)
 {
   DMBoard* board = &DMBoard::instance();
     
@@ -87,16 +86,16 @@
   {
     board->setLED(DMBoard::Led4, false);
     board->setLED(DMBoard::Led1, true);
-    Thread::wait(300);
+    ThisThread::sleep_for(300);
     board->setLED(DMBoard::Led1, false);
     board->setLED(DMBoard::Led2, true);
-    Thread::wait(300);
+    ThisThread::sleep_for(300);
     board->setLED(DMBoard::Led2, false);
     board->setLED(DMBoard::Led3, true);
-    Thread::wait(300);
+    ThisThread::sleep_for(300);
     board->setLED(DMBoard::Led3, false);
     board->setLED(DMBoard::Led4, true);
-    Thread::wait(300);
+    ThisThread::sleep_for(300);
   }
 }
 
@@ -164,7 +163,7 @@
 }
 
 #define SWIM_TASK_PREFIX  "[SWIM] "
-void swimTask(void const* args)
+void swimTask(void)
 {
   RtosLog* log = DMBoard::instance().logger();
     
@@ -206,34 +205,36 @@
 #if defined(DM_BOARD_USE_ETHERNET)
 
   #define NET_TASK_PREFIX  "[NET] "  
-  void netTask(void const* args)
+  void netTask(void)
   {
     RtosLog* log = DMBoard::instance().logger();
-    log->printf(NET_TASK_PREFIX"EthernetInterface Setting up...\r\n");
-    if(eth.init()!=0) {                             //for DHCP Server
-       //if(eth.init(IPAddress,NetMasks,Gateway)!=0) { //for Static IP Address
-       log->printf(NET_TASK_PREFIX"EthernetInterface Initialize Error \r\n");
-       mbed_die();
-    }
-    while (eth.connect() != 0) {
-       Thread::wait(1000);
-    }
-    
-    ethInitialized = true;
-    ethUsingDHCP = true;
+    log->printf(NET_TASK_PREFIX"EthernetInterface Setting up...\r\n"); 
+
+	nsapi_error_t net_err = eth.connect();
+
+	if (net_err != NSAPI_ERROR_OK) {
+		log->printf(NET_TASK_PREFIX"EthernetInterface connect Error %d\r\n", net_err);
+	}
+	else {
+
+    	ethInitialized = true;
+    	ethUsingDHCP = true;
     
-    log->printf(NET_TASK_PREFIX"IP Address is %s\r\n", eth.getIPAddress());
-    log->printf(NET_TASK_PREFIX"NetMask is %s\r\n", eth.getNetworkMask());
-    log->printf(NET_TASK_PREFIX"Gateway Address is %s\r\n", eth.getGateway());
-    log->printf(NET_TASK_PREFIX"Ethernet Setup OK\r\n");
+    	log->printf(NET_TASK_PREFIX"IP Address is %s\r\n", eth.get_ip_address());
+    	log->printf(NET_TASK_PREFIX"NetMask is %s\r\n", eth.get_netmask());
+    	log->printf(NET_TASK_PREFIX"Gateway Address is %s\r\n", eth.get_gateway());
+    	log->printf(NET_TASK_PREFIX"Ethernet Setup OK\r\n");
   
-    HTTPServerAddHandler<SimpleHandler>("/hello"); //Default handler
-    FSHandler::mount("/usb", "/");
-    HTTPServerAddHandler<FSHandler>("/");
-    //HTTPServerAddHandler<RPCHandler>("/rpc");
-    //lcd.locate(0,0);
-    //lcd.printf("%s",eth.getIPAddress());
-    HTTPServerStart(80);
+    	HTTPServerAddHandler<SimpleHandler>("/hello"); //Default handler
+    	FSHandler::mount("/mci", "/");
+    	HTTPServerAddHandler<FSHandler>("/");
+    	//lcd.locate(0,0);
+    	//lcd.printf("%s",eth.getIPAddress());
+    	HTTPServerStart(80);
+
+	}    
+    
+
   }
 #endif //DM_BOARD_USE_ETHERNET
 
@@ -381,7 +382,7 @@
 
 #define USBH_TASK_PREFIX  "[USBH] "
 #define USBH_CONNECTION_EVENT   (1<<4)
-void usbHostTask(void const* args)
+void usbHostTask(void)
 {
   bool msdConnected = false;
   bool keyboardConnected = false;
@@ -391,7 +392,8 @@
   USBHostKeyboard* keyboard = new USBHostKeyboard();
   USBHostMouse* mouse = new USBHostMouse();
   USBHost* host = USBHost::getHostInst();
-  host->signalOnConnections(Thread::gettid(), USBH_CONNECTION_EVENT);
+  EventFlags connectionEvent;
+  host->signalOnConnections(&connectionEvent, USBH_CONNECTION_EVENT);
 
   RtosLog* log = DMBoard::instance().logger();
     
@@ -400,10 +402,11 @@
   prepareCursor(false);
 
   while (true) {
+
     // wait for connect/disconnect message from USBHost
-    Thread::signal_wait(USBH_CONNECTION_EVENT);
+    connectionEvent.wait_any(USBH_CONNECTION_EVENT);
     log->printf(USBH_TASK_PREFIX"got USB event\n");
-      
+
     if (msd->connected()) {
       if (!msdConnected) {
         msdConnected = true;
@@ -462,6 +465,7 @@
         prepareCursor(true);
       }
     }
+
   }
 }
 
@@ -471,7 +475,7 @@
 
   #define USBD_TASK_PREFIX  "[USBD] "
   //#define USBD_CONNECTION_EVENT   (1<<4)
-  void usbDeviceTask(void const* args)
+  void usbDeviceTask(void)
   {
     DMBoard* board = &DMBoard::instance();
     RtosLog* log = board->logger();
@@ -727,10 +731,10 @@
   if (err != DMBoard::Ok) {
     log->printf("Failed to initialize the board, got error %d\r\n", err);
     log->printf("\nTERMINATING\n");
-    wait_ms(2000); // allow RtosLog to flush messages
+    ThisThread::sleep_for(2000); // allow RtosLog to flush messages
     mbed_die();
   }
-  
+
   board->buzzer(440,50);
   wait_ms(30);
   board->buzzer(660,50);
@@ -742,22 +746,32 @@
   //testRegistry();
   
   
-  Thread tAlive(aliveTask);
+  Thread tAlive;
+  tAlive.start(aliveTask);
 #if defined(DM_BOARD_USE_DISPLAY)
-  Thread tSwim(swimTask, NULL, osPriorityNormal, 8192);
+  Thread tSwim(osPriorityNormal, 8192);
+  tSwim.start(swimTask);
 #endif
+
+
+
 #if defined(DM_BOARD_USE_ETHERNET)  
-  Thread tNetwork(netTask, NULL, osPriorityNormal, 8192);
+  Thread tNetwork(osPriorityNormal, 8192);
+  tNetwork.start(netTask);
 #endif
+
 #if defined(DM_BOARD_USE_USB_HOST)
-  Thread tUSBHandler(usbHostTask, NULL, osPriorityNormal, 8192);
+  Thread tUSBHandler(osPriorityNormal, 8192);
+  tUSBHandler.start(usbHostTask);
 #elif defined(DM_BOARD_USE_USB_DEVICE)
-  Thread tUSBDev(usbDeviceTask, NULL, osPriorityNormal, 8192);
+  Thread tUSBDev(osPriorityNormal, 8192);
+  tUSBDev.start(usbDeviceTask);
 #endif
 
   while(1) { 
-    Thread::wait(5000);
+    ThisThread::sleep_for(5000);
     time_t seconds = time(NULL);
+
     log->printf("Time: %s\n", ctime(&seconds));
   }
 }