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

Committer:
alindvall
Date:
Tue Apr 28 11:49:03 2015 +0000
Revision:
29:be8b784873f5
Parent:
26:f07df116f3c9
Child:
30:e1cded731965
Updated to latest version of the DMSupport library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 26:f07df116f3c9 1 /*
embeddedartists 26:f07df116f3c9 2 * Copyright 2014 Embedded Artists AB
embeddedartists 26:f07df116f3c9 3 *
embeddedartists 26:f07df116f3c9 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 26:f07df116f3c9 5 * you may not use this file except in compliance with the License.
embeddedartists 26:f07df116f3c9 6 * You may obtain a copy of the License at
embeddedartists 26:f07df116f3c9 7 *
embeddedartists 26:f07df116f3c9 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 26:f07df116f3c9 9 *
embeddedartists 26:f07df116f3c9 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 26:f07df116f3c9 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 26:f07df116f3c9 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 26:f07df116f3c9 13 * See the License for the specific language governing permissions and
embeddedartists 26:f07df116f3c9 14 * limitations under the License.
embeddedartists 26:f07df116f3c9 15 */
embeddedartists 26:f07df116f3c9 16
embeddedartists 26:f07df116f3c9 17
embeddedartists 26:f07df116f3c9 18 #include "mbed.h"
embeddedartists 26:f07df116f3c9 19 #include "AppUSBMouse.h"
embeddedartists 26:f07df116f3c9 20 #include "lpc_swim_font.h"
embeddedartists 26:f07df116f3c9 21 #include "lpc_colors.h"
embeddedartists 26:f07df116f3c9 22 #include "USBMouse.h"
embeddedartists 26:f07df116f3c9 23
embeddedartists 26:f07df116f3c9 24 /******************************************************************************
embeddedartists 26:f07df116f3c9 25 * Defines and typedefs
embeddedartists 26:f07df116f3c9 26 *****************************************************************************/
embeddedartists 26:f07df116f3c9 27
embeddedartists 26:f07df116f3c9 28 /******************************************************************************
embeddedartists 26:f07df116f3c9 29 * Local variables
embeddedartists 26:f07df116f3c9 30 *****************************************************************************/
embeddedartists 26:f07df116f3c9 31
embeddedartists 26:f07df116f3c9 32
embeddedartists 26:f07df116f3c9 33 /******************************************************************************
embeddedartists 26:f07df116f3c9 34 * Private functions
embeddedartists 26:f07df116f3c9 35 *****************************************************************************/
embeddedartists 26:f07df116f3c9 36
embeddedartists 26:f07df116f3c9 37 void AppUSBMouse::draw()
embeddedartists 26:f07df116f3c9 38 {
embeddedartists 26:f07df116f3c9 39 // Prepare fullscreen
embeddedartists 26:f07df116f3c9 40 swim_window_open(_win,
embeddedartists 26:f07df116f3c9 41 _disp->width(), _disp->height(), // full size
embeddedartists 26:f07df116f3c9 42 (COLOR_T*)_fb,
embeddedartists 26:f07df116f3c9 43 0,0,_disp->width()-1, _disp->height()-1, // window position and size
embeddedartists 26:f07df116f3c9 44 0, // border
embeddedartists 26:f07df116f3c9 45 BLACK, WHITE, BLACK); // colors: pen, backgr, forgr
embeddedartists 26:f07df116f3c9 46
embeddedartists 26:f07df116f3c9 47 swim_put_text_centered_win(_win, "(Move PC's cursor with touch display. Press USER button to exit)", _disp->height()-30);
embeddedartists 26:f07df116f3c9 48 }
embeddedartists 26:f07df116f3c9 49
embeddedartists 26:f07df116f3c9 50 /******************************************************************************
embeddedartists 26:f07df116f3c9 51 * Public functions
embeddedartists 26:f07df116f3c9 52 *****************************************************************************/
embeddedartists 26:f07df116f3c9 53
embeddedartists 26:f07df116f3c9 54 AppUSBMouse::AppUSBMouse() : _disp(NULL), _win(NULL), _fb(NULL)
embeddedartists 26:f07df116f3c9 55 {
embeddedartists 26:f07df116f3c9 56 _coords[0].z = _coords[1].z = 0;
embeddedartists 26:f07df116f3c9 57 }
embeddedartists 26:f07df116f3c9 58
embeddedartists 26:f07df116f3c9 59 AppUSBMouse::~AppUSBMouse()
embeddedartists 26:f07df116f3c9 60 {
embeddedartists 26:f07df116f3c9 61 teardown();
embeddedartists 26:f07df116f3c9 62 }
embeddedartists 26:f07df116f3c9 63
embeddedartists 26:f07df116f3c9 64 bool AppUSBMouse::setup()
embeddedartists 26:f07df116f3c9 65 {
embeddedartists 26:f07df116f3c9 66 _disp = DMBoard::instance().display();
embeddedartists 26:f07df116f3c9 67 _win = (SWIM_WINDOW_T*)malloc(sizeof(SWIM_WINDOW_T));
embeddedartists 26:f07df116f3c9 68 _fb = _disp->allocateFramebuffer();
embeddedartists 26:f07df116f3c9 69
embeddedartists 26:f07df116f3c9 70 return (_win != NULL && _fb != NULL);
embeddedartists 26:f07df116f3c9 71 }
embeddedartists 26:f07df116f3c9 72
embeddedartists 26:f07df116f3c9 73 void AppUSBMouse::runToCompletion()
embeddedartists 26:f07df116f3c9 74 {
embeddedartists 26:f07df116f3c9 75 bool done = false;
embeddedartists 26:f07df116f3c9 76 draw();
embeddedartists 26:f07df116f3c9 77 void* oldFB = _disp->swapFramebuffer(_fb);
embeddedartists 26:f07df116f3c9 78
embeddedartists 26:f07df116f3c9 79 DMBoard* board = &DMBoard::instance();
embeddedartists 26:f07df116f3c9 80 RtosLog* log = board->logger();
embeddedartists 26:f07df116f3c9 81
embeddedartists 26:f07df116f3c9 82 USBMouse mouse;
embeddedartists 26:f07df116f3c9 83
embeddedartists 26:f07df116f3c9 84 // Wait for touches
embeddedartists 26:f07df116f3c9 85 TouchPanel* touch = DMBoard::instance().touchPanel();
embeddedartists 26:f07df116f3c9 86 int set = 0;
embeddedartists 26:f07df116f3c9 87 touch_coordinate_t* last = NULL;
embeddedartists 26:f07df116f3c9 88 touch_coordinate_t* current = &_coords[set];
embeddedartists 26:f07df116f3c9 89 while(!done) {
embeddedartists 26:f07df116f3c9 90 // wait for a new touch signal (signal is sent from AppLauncher,
embeddedartists 26:f07df116f3c9 91 // which listens for touch events)
embeddedartists 26:f07df116f3c9 92 osEvent evt = Thread::signal_wait(0x1, 50);
embeddedartists 26:f07df116f3c9 93 if (evt.status == osEventTimeout) {
embeddedartists 26:f07df116f3c9 94 if (board->buttonPressed()) {
embeddedartists 26:f07df116f3c9 95 done = true;
embeddedartists 26:f07df116f3c9 96 }
embeddedartists 26:f07df116f3c9 97 } else {
embeddedartists 26:f07df116f3c9 98 if (touch->read(current, 1) == TouchPanel::TouchError_Ok) {
embeddedartists 26:f07df116f3c9 99 if (current->z == 0) {
embeddedartists 26:f07df116f3c9 100 // lifted the finger so we have to think of the next touch
embeddedartists 26:f07df116f3c9 101 // event as the first one (otherwise the relative movement
embeddedartists 26:f07df116f3c9 102 // will be wrong)
embeddedartists 26:f07df116f3c9 103 last = NULL;
embeddedartists 26:f07df116f3c9 104 }
embeddedartists 26:f07df116f3c9 105 if (last != NULL) {
embeddedartists 26:f07df116f3c9 106 int moveX = current->x - last->x;
embeddedartists 26:f07df116f3c9 107 int moveY = current->y - last->y;
embeddedartists 26:f07df116f3c9 108 if (moveX != 0 && moveY != 0) {
embeddedartists 26:f07df116f3c9 109 mouse.move(current->x - last->x, current->y - last->y);
embeddedartists 26:f07df116f3c9 110 //log->printf("{%3d,%3d} -> {%3d, %3d}\n", last->x, last->y, current->x, current->y);
embeddedartists 26:f07df116f3c9 111 //log->printf("move(%4d, %4d)\n", moveX, moveY);
embeddedartists 26:f07df116f3c9 112 }
embeddedartists 26:f07df116f3c9 113 }
embeddedartists 26:f07df116f3c9 114 last = current;
embeddedartists 26:f07df116f3c9 115 current = &_coords[(++set)&1];
embeddedartists 26:f07df116f3c9 116 }
embeddedartists 26:f07df116f3c9 117 }
embeddedartists 26:f07df116f3c9 118 }
embeddedartists 26:f07df116f3c9 119
embeddedartists 26:f07df116f3c9 120 // User has clicked the button, restore the original FB
embeddedartists 26:f07df116f3c9 121 _disp->swapFramebuffer(oldFB);
embeddedartists 26:f07df116f3c9 122 swim_window_close(_win);
embeddedartists 26:f07df116f3c9 123 }
embeddedartists 26:f07df116f3c9 124
embeddedartists 26:f07df116f3c9 125 bool AppUSBMouse::teardown()
embeddedartists 26:f07df116f3c9 126 {
embeddedartists 26:f07df116f3c9 127 if (_win != NULL) {
embeddedartists 26:f07df116f3c9 128 free(_win);
embeddedartists 26:f07df116f3c9 129 _win = NULL;
embeddedartists 26:f07df116f3c9 130 }
embeddedartists 26:f07df116f3c9 131 if (_fb != NULL) {
embeddedartists 26:f07df116f3c9 132 free(_fb);
embeddedartists 26:f07df116f3c9 133 _fb = NULL;
embeddedartists 26:f07df116f3c9 134 }
embeddedartists 26:f07df116f3c9 135 return true;
embeddedartists 26:f07df116f3c9 136 }