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:
embeddedartists
Date:
Mon Nov 04 14:33:29 2019 +0000
Revision:
30:e1cded731965
Parent:
24:768f5958c308
More updates related to mbed OS 5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 24:768f5958c308 1 /*
embeddedartists 24:768f5958c308 2 * Copyright 2014 Embedded Artists AB
embeddedartists 24:768f5958c308 3 *
embeddedartists 24:768f5958c308 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 24:768f5958c308 5 * you may not use this file except in compliance with the License.
embeddedartists 24:768f5958c308 6 * You may obtain a copy of the License at
embeddedartists 24:768f5958c308 7 *
embeddedartists 24:768f5958c308 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 24:768f5958c308 9 *
embeddedartists 24:768f5958c308 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 24:768f5958c308 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 24:768f5958c308 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 24:768f5958c308 13 * See the License for the specific language governing permissions and
embeddedartists 24:768f5958c308 14 * limitations under the License.
embeddedartists 24:768f5958c308 15 */
embeddedartists 24:768f5958c308 16
embeddedartists 24:768f5958c308 17
embeddedartists 24:768f5958c308 18 #include "mbed.h"
embeddedartists 24:768f5958c308 19 #include "EthernetInterface.h"
embeddedartists 24:768f5958c308 20 #include "AppDraw.h"
embeddedartists 24:768f5958c308 21 #include "lpc_swim_font.h"
embeddedartists 24:768f5958c308 22 #include "lpc_colors.h"
embeddedartists 24:768f5958c308 23 #include "image_data.h"
embeddedartists 24:768f5958c308 24
embeddedartists 24:768f5958c308 25 /******************************************************************************
embeddedartists 24:768f5958c308 26 * Defines and typedefs
embeddedartists 24:768f5958c308 27 *****************************************************************************/
embeddedartists 24:768f5958c308 28
embeddedartists 24:768f5958c308 29 #define BOX_SIDE 192 //256
embeddedartists 24:768f5958c308 30
embeddedartists 24:768f5958c308 31 #define BTN_WIDTH 65
embeddedartists 24:768f5958c308 32 #define BTN_HEIGHT 40
embeddedartists 24:768f5958c308 33 #define BTN_OFF 20
embeddedartists 24:768f5958c308 34
embeddedartists 24:768f5958c308 35 /******************************************************************************
embeddedartists 24:768f5958c308 36 * Local variables
embeddedartists 24:768f5958c308 37 *****************************************************************************/
embeddedartists 24:768f5958c308 38
embeddedartists 24:768f5958c308 39 static const COLOR_T COLORS[] = {
embeddedartists 24:768f5958c308 40 RED,
embeddedartists 24:768f5958c308 41 GREEN,
embeddedartists 24:768f5958c308 42 BLUE,
embeddedartists 24:768f5958c308 43 CYAN,
embeddedartists 24:768f5958c308 44 MAGENTA,
embeddedartists 24:768f5958c308 45 YELLOW,
embeddedartists 24:768f5958c308 46 BLACK,
embeddedartists 24:768f5958c308 47 };
embeddedartists 24:768f5958c308 48
embeddedartists 24:768f5958c308 49 /******************************************************************************
embeddedartists 24:768f5958c308 50 * Private functions
embeddedartists 24:768f5958c308 51 *****************************************************************************/
embeddedartists 24:768f5958c308 52
embeddedartists 24:768f5958c308 53 static void buttonClicked(uint32_t x)
embeddedartists 24:768f5958c308 54 {
embeddedartists 24:768f5958c308 55 bool* done = (bool*)x;
embeddedartists 24:768f5958c308 56 *done = true;
embeddedartists 24:768f5958c308 57 }
embeddedartists 24:768f5958c308 58
embeddedartists 24:768f5958c308 59 void AppDraw::draw()
embeddedartists 24:768f5958c308 60 {
embeddedartists 24:768f5958c308 61 // Prepare fullscreen
embeddedartists 24:768f5958c308 62 swim_window_open(_win,
embeddedartists 24:768f5958c308 63 _disp->width(), _disp->height(), // full size
embeddedartists 24:768f5958c308 64 (COLOR_T*)_fb,
embeddedartists 24:768f5958c308 65 0,0,_disp->width()-1, _disp->height()-1, // window position and size
embeddedartists 24:768f5958c308 66 0, // border
embeddedartists 24:768f5958c308 67 WHITE, WHITE, BLACK); // colors: pen, backgr, forgr
embeddedartists 24:768f5958c308 68
embeddedartists 24:768f5958c308 69 _btn = new ImageButton(_win->fb, _win->xpmax - BTN_OFF - BTN_WIDTH, _win->ypmax - BTN_OFF - BTN_HEIGHT, BTN_WIDTH, BTN_HEIGHT);
embeddedartists 24:768f5958c308 70 _btn->loadImages(img_ok, img_size_ok);
embeddedartists 24:768f5958c308 71 _btn->draw();
embeddedartists 24:768f5958c308 72 }
embeddedartists 24:768f5958c308 73
embeddedartists 24:768f5958c308 74 /******************************************************************************
embeddedartists 24:768f5958c308 75 * Public functions
embeddedartists 24:768f5958c308 76 *****************************************************************************/
embeddedartists 24:768f5958c308 77
embeddedartists 24:768f5958c308 78 AppDraw::AppDraw() : _disp(NULL), _win(NULL), _fb(NULL), _btn(NULL)
embeddedartists 24:768f5958c308 79 {
embeddedartists 24:768f5958c308 80 }
embeddedartists 24:768f5958c308 81
embeddedartists 24:768f5958c308 82 AppDraw::~AppDraw()
embeddedartists 24:768f5958c308 83 {
embeddedartists 24:768f5958c308 84 teardown();
embeddedartists 24:768f5958c308 85 }
embeddedartists 24:768f5958c308 86
embeddedartists 24:768f5958c308 87 bool AppDraw::setup()
embeddedartists 24:768f5958c308 88 {
embeddedartists 24:768f5958c308 89 _disp = DMBoard::instance().display();
embeddedartists 24:768f5958c308 90 _win = (SWIM_WINDOW_T*)malloc(sizeof(SWIM_WINDOW_T));
embeddedartists 24:768f5958c308 91 _fb = _disp->allocateFramebuffer();
embeddedartists 24:768f5958c308 92
embeddedartists 24:768f5958c308 93 return (_win != NULL && _fb != NULL);
embeddedartists 24:768f5958c308 94 }
embeddedartists 24:768f5958c308 95
embeddedartists 24:768f5958c308 96 void AppDraw::runToCompletion()
embeddedartists 24:768f5958c308 97 {
embeddedartists 24:768f5958c308 98 // Alternative 1: use the calling thread's context to run in
embeddedartists 24:768f5958c308 99 bool done = false;
embeddedartists 24:768f5958c308 100 draw();
embeddedartists 24:768f5958c308 101 _btn->setAction(buttonClicked, (uint32_t)&done);
embeddedartists 24:768f5958c308 102 void* oldFB = _disp->swapFramebuffer(_fb);
embeddedartists 24:768f5958c308 103
embeddedartists 24:768f5958c308 104 // Wait for touches
embeddedartists 24:768f5958c308 105 TouchPanel* touch = DMBoard::instance().touchPanel();
embeddedartists 24:768f5958c308 106 bool ignore;
embeddedartists 24:768f5958c308 107 int fingers = 0;
embeddedartists 24:768f5958c308 108 touch->info(&ignore, &fingers, &ignore);
embeddedartists 24:768f5958c308 109 if (fingers > MaxSupportedFingers) {
embeddedartists 24:768f5958c308 110 fingers = MaxSupportedFingers;
embeddedartists 24:768f5958c308 111 }
embeddedartists 24:768f5958c308 112 while(!done) {
embeddedartists 24:768f5958c308 113 // wait for a new touch signal (signal is sent from AppLauncher,
embeddedartists 24:768f5958c308 114 // which listens for touch events)
embeddedartists 30:e1cded731965 115 ThisThread::flags_wait_all(0x1);
embeddedartists 24:768f5958c308 116 if (touch->read(_coords, fingers) == TouchPanel::TouchError_Ok) {
embeddedartists 24:768f5958c308 117 for (int i = 0; i < fingers; i++) {
embeddedartists 24:768f5958c308 118 if (_coords[i].z > 0) {
embeddedartists 24:768f5958c308 119 _win->pen = COLORS[i];
embeddedartists 24:768f5958c308 120 swim_put_circle(_win, _coords[i].x, _coords[i].y, 2, 1);
embeddedartists 24:768f5958c308 121 }
embeddedartists 24:768f5958c308 122 }
embeddedartists 24:768f5958c308 123 if (_btn->handle(_coords[0].x, _coords[0].y, _coords[0].z > 0)) {
embeddedartists 24:768f5958c308 124 _btn->draw();
embeddedartists 24:768f5958c308 125 }
embeddedartists 24:768f5958c308 126 }
embeddedartists 24:768f5958c308 127 }
embeddedartists 24:768f5958c308 128
embeddedartists 24:768f5958c308 129 // User has clicked the button, restore the original FB
embeddedartists 24:768f5958c308 130 _disp->swapFramebuffer(oldFB);
embeddedartists 24:768f5958c308 131 swim_window_close(_win);
embeddedartists 24:768f5958c308 132 }
embeddedartists 24:768f5958c308 133
embeddedartists 24:768f5958c308 134 bool AppDraw::teardown()
embeddedartists 24:768f5958c308 135 {
embeddedartists 24:768f5958c308 136 if (_win != NULL) {
embeddedartists 24:768f5958c308 137 free(_win);
embeddedartists 24:768f5958c308 138 _win = NULL;
embeddedartists 24:768f5958c308 139 }
embeddedartists 24:768f5958c308 140 if (_fb != NULL) {
embeddedartists 24:768f5958c308 141 free(_fb);
embeddedartists 24:768f5958c308 142 _fb = NULL;
embeddedartists 24:768f5958c308 143 }
embeddedartists 24:768f5958c308 144 if (_btn != NULL) {
embeddedartists 24:768f5958c308 145 delete _btn;
embeddedartists 24:768f5958c308 146 _btn = NULL;
embeddedartists 24:768f5958c308 147 }
embeddedartists 24:768f5958c308 148 return true;
embeddedartists 24:768f5958c308 149 }