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

Revision:
26:f07df116f3c9
Child:
30:e1cded731965
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AppUSBMouse.cpp	Mon Mar 09 16:21:26 2015 +0100
@@ -0,0 +1,136 @@
+/*
+ *  Copyright 2014 Embedded Artists AB
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+#include "mbed.h"
+#include "AppUSBMouse.h"
+#include "lpc_swim_font.h"
+#include "lpc_colors.h"
+#include "USBMouse.h"
+
+/******************************************************************************
+ * Defines and typedefs
+ *****************************************************************************/
+
+/******************************************************************************
+ * Local variables
+ *****************************************************************************/
+
+
+/******************************************************************************
+ * Private functions
+ *****************************************************************************/
+
+void AppUSBMouse::draw()
+{
+    // Prepare fullscreen
+    swim_window_open(_win, 
+                   _disp->width(), _disp->height(),         // full size
+                   (COLOR_T*)_fb,
+                   0,0,_disp->width()-1, _disp->height()-1, // window position and size
+                   0,                                       // border
+                   BLACK, WHITE, BLACK);                    // colors: pen, backgr, forgr
+
+    swim_put_text_centered_win(_win, "(Move PC's cursor with touch display. Press USER button to exit)", _disp->height()-30);
+}
+
+/******************************************************************************
+ * Public functions
+ *****************************************************************************/
+
+AppUSBMouse::AppUSBMouse() : _disp(NULL), _win(NULL), _fb(NULL)
+{
+  _coords[0].z = _coords[1].z = 0;
+}
+
+AppUSBMouse::~AppUSBMouse()
+{
+    teardown();
+}
+
+bool AppUSBMouse::setup()
+{
+    _disp = DMBoard::instance().display();
+    _win = (SWIM_WINDOW_T*)malloc(sizeof(SWIM_WINDOW_T));
+    _fb = _disp->allocateFramebuffer();
+
+    return (_win != NULL && _fb != NULL);
+}
+
+void AppUSBMouse::runToCompletion()
+{
+    bool done = false;
+    draw();
+    void* oldFB = _disp->swapFramebuffer(_fb);
+    
+    DMBoard* board = &DMBoard::instance();
+    RtosLog* log = board->logger();
+    
+    USBMouse mouse;
+    
+    // Wait for touches
+    TouchPanel* touch = DMBoard::instance().touchPanel();
+    int set = 0;
+    touch_coordinate_t* last = NULL;
+    touch_coordinate_t* current = &_coords[set];
+    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) {
+        if (board->buttonPressed()) {
+          done = true;
+        }
+      } else {
+        if (touch->read(current, 1) == TouchPanel::TouchError_Ok) {
+          if (current->z == 0) {
+            // lifted the finger so we have to think of the next touch
+            // event as the first one (otherwise the relative movement
+            // will be wrong)
+            last = NULL;
+          }
+          if (last != NULL) {
+            int moveX = current->x - last->x;
+            int moveY = current->y - last->y;
+            if (moveX != 0 && moveY != 0) {
+              mouse.move(current->x - last->x, current->y - last->y);
+              //log->printf("{%3d,%3d} -> {%3d, %3d}\n", last->x, last->y, current->x, current->y);
+              //log->printf("move(%4d, %4d)\n", moveX, moveY);
+            }
+          }
+          last = current;
+          current = &_coords[(++set)&1];
+        }
+      }
+    }
+    
+    // User has clicked the button, restore the original FB
+    _disp->swapFramebuffer(oldFB);
+    swim_window_close(_win);
+}
+
+bool AppUSBMouse::teardown()
+{
+    if (_win != NULL) {
+        free(_win);
+        _win = NULL;
+    }
+    if (_fb != NULL) {
+        free(_fb);
+        _fb = NULL;
+    }
+    return true;
+}