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:
Thu Jan 08 19:31:23 2015 +0100
Revision:
13:57e65aba9802
Child:
16:77f4f42eb6a7
- Moved AppImageViewer and AppStatus here from DMBasicGUI
- Added new AppNetworkSettings
- New images in image_data

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 13:57e65aba9802 1 /*
embeddedartists 13:57e65aba9802 2 * Copyright 2014 Embedded Artists AB
embeddedartists 13:57e65aba9802 3 *
embeddedartists 13:57e65aba9802 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 13:57e65aba9802 5 * you may not use this file except in compliance with the License.
embeddedartists 13:57e65aba9802 6 * You may obtain a copy of the License at
embeddedartists 13:57e65aba9802 7 *
embeddedartists 13:57e65aba9802 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 13:57e65aba9802 9 *
embeddedartists 13:57e65aba9802 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 13:57e65aba9802 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 13:57e65aba9802 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 13:57e65aba9802 13 * See the License for the specific language governing permissions and
embeddedartists 13:57e65aba9802 14 * limitations under the License.
embeddedartists 13:57e65aba9802 15 */
embeddedartists 13:57e65aba9802 16
embeddedartists 13:57e65aba9802 17
embeddedartists 13:57e65aba9802 18 #include "mbed.h"
embeddedartists 13:57e65aba9802 19 #include "EthernetInterface.h"
embeddedartists 13:57e65aba9802 20 #include "AppStatus.h"
embeddedartists 13:57e65aba9802 21 #include "lpc_swim_font.h"
embeddedartists 13:57e65aba9802 22 #include "image_data.h"
embeddedartists 13:57e65aba9802 23
embeddedartists 13:57e65aba9802 24 /******************************************************************************
embeddedartists 13:57e65aba9802 25 * Defines and typedefs
embeddedartists 13:57e65aba9802 26 *****************************************************************************/
embeddedartists 13:57e65aba9802 27
embeddedartists 13:57e65aba9802 28 #define HEADER_X_OFF 20
embeddedartists 13:57e65aba9802 29 #define HEADER_Y_SPACING 20
embeddedartists 13:57e65aba9802 30 #define ITEM_CAPTION_X_OFF 40
embeddedartists 13:57e65aba9802 31 #define ITEM_CAPTION_Y_SPACING (swim_get_font_height(_win) + 5)
embeddedartists 13:57e65aba9802 32 #define ITEM_VALUE_X_OFF 140
embeddedartists 13:57e65aba9802 33 #define COL3_OFF 230
embeddedartists 13:57e65aba9802 34
embeddedartists 13:57e65aba9802 35 #define BTN_WIDTH 40
embeddedartists 13:57e65aba9802 36 #define BTN_HEIGHT 40
embeddedartists 13:57e65aba9802 37 #define BTN_OFF 20
embeddedartists 13:57e65aba9802 38
embeddedartists 13:57e65aba9802 39 /******************************************************************************
embeddedartists 13:57e65aba9802 40 * Global variables
embeddedartists 13:57e65aba9802 41 *****************************************************************************/
embeddedartists 13:57e65aba9802 42
embeddedartists 13:57e65aba9802 43 extern EthernetInterface eth;
embeddedartists 13:57e65aba9802 44 extern bool ethInitialized;
embeddedartists 13:57e65aba9802 45 extern bool ethUsingDHCP;
embeddedartists 13:57e65aba9802 46
embeddedartists 13:57e65aba9802 47 /******************************************************************************
embeddedartists 13:57e65aba9802 48 * Private functions
embeddedartists 13:57e65aba9802 49 *****************************************************************************/
embeddedartists 13:57e65aba9802 50
embeddedartists 13:57e65aba9802 51 static void buttonClicked(uint32_t x)
embeddedartists 13:57e65aba9802 52 {
embeddedartists 13:57e65aba9802 53 bool* done = (bool*)x;
embeddedartists 13:57e65aba9802 54 *done = true;
embeddedartists 13:57e65aba9802 55 }
embeddedartists 13:57e65aba9802 56
embeddedartists 13:57e65aba9802 57 void AppStatus::draw()
embeddedartists 13:57e65aba9802 58 {
embeddedartists 13:57e65aba9802 59 // Prepare fullscreen
embeddedartists 13:57e65aba9802 60 swim_window_open(_win,
embeddedartists 13:57e65aba9802 61 _disp->width(), _disp->height(), // full size
embeddedartists 13:57e65aba9802 62 (COLOR_T*)_fb,
embeddedartists 13:57e65aba9802 63 0,0,_disp->width()-1, _disp->height()-1, // window position and size
embeddedartists 13:57e65aba9802 64 1, // border
embeddedartists 13:57e65aba9802 65 WHITE, BLUE, BLACK); // colors: pen, backgr, forgr
embeddedartists 13:57e65aba9802 66 swim_set_title(_win, "Application Status", BLACK);
embeddedartists 13:57e65aba9802 67
embeddedartists 13:57e65aba9802 68 char buff[120];
embeddedartists 13:57e65aba9802 69
embeddedartists 13:57e65aba9802 70 // Column 1
embeddedartists 13:57e65aba9802 71 swim_put_text_xy(_win, "Ethernet:", HEADER_X_OFF, HEADER_Y_SPACING);
embeddedartists 13:57e65aba9802 72 swim_put_text_xy(_win, "IP Address:", ITEM_CAPTION_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 1);
embeddedartists 13:57e65aba9802 73 swim_put_text_xy(_win, "NetMask:", ITEM_CAPTION_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 2);
embeddedartists 13:57e65aba9802 74 swim_put_text_xy(_win, "Gateway Address:", ITEM_CAPTION_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 3);
embeddedartists 13:57e65aba9802 75 swim_put_text_xy(_win, "MAC Address:", ITEM_CAPTION_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 4);
embeddedartists 13:57e65aba9802 76 swim_put_text_xy(_win, "DHCP/Static IP:", ITEM_CAPTION_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 5);
embeddedartists 13:57e65aba9802 77
embeddedartists 13:57e65aba9802 78 // Column 2
embeddedartists 13:57e65aba9802 79 if (ethInitialized) {
embeddedartists 13:57e65aba9802 80 swim_put_text_xy(_win, eth.getIPAddress(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 1);
embeddedartists 13:57e65aba9802 81 swim_put_text_xy(_win, eth.getNetworkMask(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 2);
embeddedartists 13:57e65aba9802 82 swim_put_text_xy(_win, eth.getGateway(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 3);
embeddedartists 13:57e65aba9802 83 swim_put_text_xy(_win, eth.getMACAddress(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 4);
embeddedartists 13:57e65aba9802 84 swim_put_text_xy(_win, ethUsingDHCP?"DHCP":"Static IP", ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 5);
embeddedartists 13:57e65aba9802 85 } else {
embeddedartists 13:57e65aba9802 86 swim_put_text_xy(_win, "Not Initialized", ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 1);
embeddedartists 13:57e65aba9802 87 swim_put_text_xy(_win, "Not Initialized", ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 2);
embeddedartists 13:57e65aba9802 88 swim_put_text_xy(_win, "Not Initialized", ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 3);
embeddedartists 13:57e65aba9802 89 swim_put_text_xy(_win, "Not Initialized", ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 4);
embeddedartists 13:57e65aba9802 90 swim_put_text_xy(_win, "Not Initialized", ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 5);
embeddedartists 13:57e65aba9802 91 }
embeddedartists 13:57e65aba9802 92
embeddedartists 13:57e65aba9802 93 // Column 3
embeddedartists 13:57e65aba9802 94 swim_put_text_xy(_win, "Display:", COL3_OFF+HEADER_X_OFF, HEADER_Y_SPACING);
embeddedartists 13:57e65aba9802 95 swim_put_text_xy(_win, "Size:", COL3_OFF+ITEM_CAPTION_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 1);
embeddedartists 13:57e65aba9802 96 swim_put_text_xy(_win, "Resolutions:", COL3_OFF+ITEM_CAPTION_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 2);
embeddedartists 13:57e65aba9802 97 swim_put_text_xy(_win, " 16bit RGB565:", COL3_OFF+ITEM_CAPTION_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 3);
embeddedartists 13:57e65aba9802 98 swim_put_text_xy(_win, " 18bit RGB666:", COL3_OFF+ITEM_CAPTION_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 4);
embeddedartists 13:57e65aba9802 99 swim_put_text_xy(_win, " 24bit RGB888:", COL3_OFF+ITEM_CAPTION_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 5);
embeddedartists 13:57e65aba9802 100 swim_put_text_xy(_win, "Landscape:", COL3_OFF+ITEM_CAPTION_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 6);
embeddedartists 13:57e65aba9802 101
embeddedartists 13:57e65aba9802 102 // Column 4
embeddedartists 13:57e65aba9802 103 sprintf(buff, "%d x %d pixels", _disp->width(), _disp->height());
embeddedartists 13:57e65aba9802 104 swim_put_text_xy(_win, buff, COL3_OFF+ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 1);
embeddedartists 13:57e65aba9802 105
embeddedartists 13:57e65aba9802 106 sprintf(buff, "%s %s", _disp->isSupported(Display::Resolution_16bit_rgb565)?"Supported":"N/A", _disp->currentResolution()==Display::Resolution_16bit_rgb565?" (Active)":"");
embeddedartists 13:57e65aba9802 107 swim_put_text_xy(_win, buff, COL3_OFF+ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 3);
embeddedartists 13:57e65aba9802 108
embeddedartists 13:57e65aba9802 109 sprintf(buff, "%s %s", _disp->isSupported(Display::Resolution_18bit_rgb666)?"Supported":"N/A", _disp->currentResolution()==Display::Resolution_18bit_rgb666?" (Active)":"");
embeddedartists 13:57e65aba9802 110 swim_put_text_xy(_win, buff, COL3_OFF+ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 4);
embeddedartists 13:57e65aba9802 111
embeddedartists 13:57e65aba9802 112 sprintf(buff, "%s %s", _disp->isSupported(Display::Resolution_24bit_rgb888)?"Supported":"N/A", _disp->currentResolution()==Display::Resolution_24bit_rgb888?" (Active)":"");
embeddedartists 13:57e65aba9802 113 swim_put_text_xy(_win, buff, COL3_OFF+ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 5);
embeddedartists 13:57e65aba9802 114
embeddedartists 13:57e65aba9802 115 sprintf(buff, "%s", _disp->landscape()?"YES":"NO");
embeddedartists 13:57e65aba9802 116 swim_put_text_xy(_win, buff, COL3_OFF+ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 6);
embeddedartists 13:57e65aba9802 117
embeddedartists 13:57e65aba9802 118 _btn = new ImageButton(_win->fb, _win->xpmax - BTN_OFF - BTN_WIDTH, _win->ypmax - BTN_OFF - BTN_HEIGHT, BTN_WIDTH, BTN_HEIGHT);
embeddedartists 13:57e65aba9802 119 _btn->loadImages(img_ok, img_size_ok);
embeddedartists 13:57e65aba9802 120 _btn->draw();
embeddedartists 13:57e65aba9802 121 }
embeddedartists 13:57e65aba9802 122
embeddedartists 13:57e65aba9802 123 /******************************************************************************
embeddedartists 13:57e65aba9802 124 * Public functions
embeddedartists 13:57e65aba9802 125 *****************************************************************************/
embeddedartists 13:57e65aba9802 126
embeddedartists 13:57e65aba9802 127 AppStatus::AppStatus() : _disp(NULL), _win(NULL), _fb(NULL), _btn(NULL)
embeddedartists 13:57e65aba9802 128 {
embeddedartists 13:57e65aba9802 129 }
embeddedartists 13:57e65aba9802 130
embeddedartists 13:57e65aba9802 131 AppStatus::~AppStatus()
embeddedartists 13:57e65aba9802 132 {
embeddedartists 13:57e65aba9802 133 teardown();
embeddedartists 13:57e65aba9802 134 }
embeddedartists 13:57e65aba9802 135
embeddedartists 13:57e65aba9802 136 bool AppStatus::setup()
embeddedartists 13:57e65aba9802 137 {
embeddedartists 13:57e65aba9802 138 _disp = DMBoard::instance().display();
embeddedartists 13:57e65aba9802 139 _win = (SWIM_WINDOW_T*)malloc(sizeof(SWIM_WINDOW_T));
embeddedartists 13:57e65aba9802 140 _fb = _disp->allocateFramebuffer();
embeddedartists 13:57e65aba9802 141
embeddedartists 13:57e65aba9802 142 return (_win != NULL && _fb != NULL);
embeddedartists 13:57e65aba9802 143 }
embeddedartists 13:57e65aba9802 144
embeddedartists 13:57e65aba9802 145 void AppStatus::runToCompletion()
embeddedartists 13:57e65aba9802 146 {
embeddedartists 13:57e65aba9802 147 // Alternative 1: use the calling thread's context to run in
embeddedartists 13:57e65aba9802 148 bool done = false;
embeddedartists 13:57e65aba9802 149 draw();
embeddedartists 13:57e65aba9802 150 _btn->setAction(buttonClicked, (uint32_t)&done);
embeddedartists 13:57e65aba9802 151 void* oldFB = _disp->swapFramebuffer(_fb);
embeddedartists 13:57e65aba9802 152
embeddedartists 13:57e65aba9802 153 // Wait for touches
embeddedartists 13:57e65aba9802 154 TouchPanel* touch = DMBoard::instance().touchPanel();
embeddedartists 13:57e65aba9802 155 TouchPanel::touchCoordinate_t coord;
embeddedartists 13:57e65aba9802 156 while(!done) {
embeddedartists 13:57e65aba9802 157 if (touch->read(coord) == TouchPanel::TouchError_Ok) {
embeddedartists 13:57e65aba9802 158 if (_btn->handle(coord.x, coord.y, coord.z > 0)) {
embeddedartists 13:57e65aba9802 159 _btn->draw();
embeddedartists 13:57e65aba9802 160 }
embeddedartists 13:57e65aba9802 161 }
embeddedartists 13:57e65aba9802 162 }
embeddedartists 13:57e65aba9802 163
embeddedartists 13:57e65aba9802 164 // User has clicked the button, restore the original FB
embeddedartists 13:57e65aba9802 165 _disp->swapFramebuffer(oldFB);
embeddedartists 13:57e65aba9802 166 swim_window_close(_win);
embeddedartists 13:57e65aba9802 167 }
embeddedartists 13:57e65aba9802 168
embeddedartists 13:57e65aba9802 169 bool AppStatus::teardown()
embeddedartists 13:57e65aba9802 170 {
embeddedartists 13:57e65aba9802 171 if (_win != NULL) {
embeddedartists 13:57e65aba9802 172 free(_win);
embeddedartists 13:57e65aba9802 173 _win = NULL;
embeddedartists 13:57e65aba9802 174 }
embeddedartists 13:57e65aba9802 175 if (_fb != NULL) {
embeddedartists 13:57e65aba9802 176 free(_fb);
embeddedartists 13:57e65aba9802 177 _fb = NULL;
embeddedartists 13:57e65aba9802 178 }
embeddedartists 13:57e65aba9802 179 if (_btn != NULL) {
embeddedartists 13:57e65aba9802 180 delete _btn;
embeddedartists 13:57e65aba9802 181 _btn = NULL;
embeddedartists 13:57e65aba9802 182 }
embeddedartists 13:57e65aba9802 183 return true;
embeddedartists 13:57e65aba9802 184 }
embeddedartists 13:57e65aba9802 185
embeddedartists 13:57e65aba9802 186