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:
27:4fe24decabf9
More updates related to mbed OS 5

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 "AppNetworkSettings.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 BTN_WIDTH 40
embeddedartists 13:57e65aba9802 29 #define BTN_HEIGHT 40
embeddedartists 13:57e65aba9802 30 #define BTN_OFF 20
embeddedartists 13:57e65aba9802 31
embeddedartists 13:57e65aba9802 32 #define ARROW_WIDTH 52
embeddedartists 13:57e65aba9802 33 #define ARROW_HEIGHT 52
embeddedartists 13:57e65aba9802 34
embeddedartists 13:57e65aba9802 35 /******************************************************************************
embeddedartists 13:57e65aba9802 36 * Private variables
embeddedartists 13:57e65aba9802 37 *****************************************************************************/
embeddedartists 13:57e65aba9802 38
embeddedartists 13:57e65aba9802 39 // Ugly but needed for callbacks
embeddedartists 13:57e65aba9802 40 static AppNetworkSettings* theApp = NULL;
embeddedartists 13:57e65aba9802 41
embeddedartists 13:57e65aba9802 42 /******************************************************************************
embeddedartists 13:57e65aba9802 43 * Private functions
embeddedartists 13:57e65aba9802 44 *****************************************************************************/
embeddedartists 13:57e65aba9802 45
embeddedartists 13:57e65aba9802 46 static void buttonClicked(uint32_t x)
embeddedartists 13:57e65aba9802 47 {
embeddedartists 13:57e65aba9802 48 bool* done = (bool*)x;
embeddedartists 13:57e65aba9802 49 *done = true;
embeddedartists 13:57e65aba9802 50 }
embeddedartists 13:57e65aba9802 51
embeddedartists 13:57e65aba9802 52 static void fieldClicked(uint32_t x)
embeddedartists 13:57e65aba9802 53 {
embeddedartists 13:57e65aba9802 54 if (theApp != NULL) {
embeddedartists 13:57e65aba9802 55 theApp->setActiveField(x);
embeddedartists 13:57e65aba9802 56 }
embeddedartists 13:57e65aba9802 57 }
embeddedartists 13:57e65aba9802 58
embeddedartists 13:57e65aba9802 59 static void increaseValue(uint32_t x)
embeddedartists 13:57e65aba9802 60 {
embeddedartists 13:57e65aba9802 61 AppNetworkSettings* app = (AppNetworkSettings*)x;
embeddedartists 13:57e65aba9802 62 app->modifyValue(1);
embeddedartists 13:57e65aba9802 63 }
embeddedartists 13:57e65aba9802 64
embeddedartists 13:57e65aba9802 65 static void decreaseValue(uint32_t x)
embeddedartists 13:57e65aba9802 66 {
embeddedartists 13:57e65aba9802 67 AppNetworkSettings* app = (AppNetworkSettings*)x;
embeddedartists 13:57e65aba9802 68 app->modifyValue(-1);
embeddedartists 13:57e65aba9802 69 }
embeddedartists 13:57e65aba9802 70
embeddedartists 13:57e65aba9802 71 static void nextField(uint32_t x)
embeddedartists 13:57e65aba9802 72 {
embeddedartists 13:57e65aba9802 73 AppNetworkSettings* app = (AppNetworkSettings*)x;
embeddedartists 13:57e65aba9802 74 app->changeActiveField(true);
embeddedartists 13:57e65aba9802 75 }
embeddedartists 13:57e65aba9802 76
embeddedartists 13:57e65aba9802 77 static void prevField(uint32_t x)
embeddedartists 13:57e65aba9802 78 {
embeddedartists 13:57e65aba9802 79 AppNetworkSettings* app = (AppNetworkSettings*)x;
embeddedartists 13:57e65aba9802 80 app->changeActiveField(false);
embeddedartists 13:57e65aba9802 81 }
embeddedartists 13:57e65aba9802 82
embeddedartists 13:57e65aba9802 83 void AppNetworkSettings::draw()
embeddedartists 13:57e65aba9802 84 {
embeddedartists 13:57e65aba9802 85 // Prepare fullscreen
embeddedartists 13:57e65aba9802 86 swim_window_open(_win,
embeddedartists 13:57e65aba9802 87 _disp->width(), _disp->height(), // full size
embeddedartists 13:57e65aba9802 88 (COLOR_T*)_fb,
embeddedartists 13:57e65aba9802 89 0,0,_disp->width()-1, _disp->height()-1, // window position and size
embeddedartists 13:57e65aba9802 90 1, // border
embeddedartists 13:57e65aba9802 91 RED,WHITE,BLACK);/*WHITE, RED, BLACK);*/ // colors: pen, backgr, forgr
embeddedartists 13:57e65aba9802 92 swim_set_pen_color(_win, WHITE);
embeddedartists 13:57e65aba9802 93 swim_set_title(_win, "Network Settings", RED);
embeddedartists 13:57e65aba9802 94 swim_set_pen_color(_win, RED);
embeddedartists 13:57e65aba9802 95
embeddedartists 13:57e65aba9802 96 //_buttons[ButtonDone] = new Button("Done", _win->fb, _win->xpmax - BTN_OFF - BTN_WIDTH, _win->ypmax - BTN_OFF - BTN_HEIGHT, BTN_WIDTH, BTN_HEIGHT);
embeddedartists 13:57e65aba9802 97
embeddedartists 13:57e65aba9802 98 ImageButton* ib;
embeddedartists 13:57e65aba9802 99
embeddedartists 13:57e65aba9802 100 ib = new ImageButton(_win->fb, _win->xpmax - 2*BTN_OFF - 2*BTN_WIDTH, _win->ypmax - BTN_OFF - BTN_HEIGHT, BTN_WIDTH, BTN_HEIGHT);
embeddedartists 13:57e65aba9802 101 ib->loadImages(img_ok, img_size_ok);
embeddedartists 13:57e65aba9802 102 ib->draw();
embeddedartists 13:57e65aba9802 103 _buttons[ButtonOk] = ib;
embeddedartists 13:57e65aba9802 104 ib = new ImageButton(_win->fb, _win->xpmax - BTN_OFF - BTN_WIDTH, _win->ypmax - BTN_OFF - BTN_HEIGHT, BTN_WIDTH, BTN_HEIGHT);
embeddedartists 13:57e65aba9802 105 ib->loadImages(img_cancel, img_size_cancel);
embeddedartists 13:57e65aba9802 106 ib->draw();
embeddedartists 13:57e65aba9802 107 _buttons[ButtonCancel] = ib;
embeddedartists 13:57e65aba9802 108
embeddedartists 13:57e65aba9802 109 ib = new ImageButton(_win->fb, 300, 40, ARROW_WIDTH, ARROW_HEIGHT);
embeddedartists 13:57e65aba9802 110 ib->loadImages(img_arrow_up, img_size_arrow_up);
embeddedartists 13:57e65aba9802 111 ib->setAction(increaseValue, (uint32_t)this);
embeddedartists 13:57e65aba9802 112 ib->draw();
embeddedartists 13:57e65aba9802 113 _buttons[ButtonUp] = ib;
embeddedartists 13:57e65aba9802 114 ib = new ImageButton(_win->fb, 300, 40+ARROW_HEIGHT+ARROW_HEIGHT, ARROW_WIDTH, ARROW_HEIGHT);
embeddedartists 13:57e65aba9802 115 ib->loadImages(img_arrow_down, img_size_arrow_down);
embeddedartists 13:57e65aba9802 116 ib->setAction(decreaseValue, (uint32_t)this);
embeddedartists 13:57e65aba9802 117 ib->draw();
embeddedartists 13:57e65aba9802 118 _buttons[ButtonDown] = ib;
embeddedartists 13:57e65aba9802 119 ib = new ImageButton(_win->fb, 300-ARROW_WIDTH/2-10, 40+ARROW_HEIGHT, ARROW_WIDTH, ARROW_HEIGHT);
embeddedartists 13:57e65aba9802 120 ib->loadImages(img_arrow_left, img_size_arrow_left);
embeddedartists 13:57e65aba9802 121 ib->setAction(prevField, (uint32_t)this);
embeddedartists 13:57e65aba9802 122 ib->draw();
embeddedartists 13:57e65aba9802 123 _buttons[ButtonLeft] = ib;
embeddedartists 13:57e65aba9802 124 ib = new ImageButton(_win->fb, 300+ARROW_WIDTH/2+10, 40+ARROW_HEIGHT, ARROW_WIDTH, ARROW_HEIGHT);
embeddedartists 13:57e65aba9802 125 ib->loadImages(img_arrow_right, img_size_arrow_right);
embeddedartists 13:57e65aba9802 126 ib->setAction(nextField, (uint32_t)this);
embeddedartists 13:57e65aba9802 127 ib->draw();
embeddedartists 13:57e65aba9802 128 _buttons[ButtonRight] = ib;
embeddedartists 13:57e65aba9802 129
embeddedartists 18:715f542538b3 130 // To avoid having each DigitButton deallocate the shared image
embeddedartists 18:715f542538b3 131 void* pointerToFree = _digitImage.pointerToFree;
embeddedartists 18:715f542538b3 132 _digitImage.pointerToFree = NULL;
embeddedartists 18:715f542538b3 133
embeddedartists 13:57e65aba9802 134 addIPField(20, ButtonIp0, "IP Address:");
embeddedartists 13:57e65aba9802 135 addIPField(20+65, ButtonMask0, "Net Mask:");
embeddedartists 13:57e65aba9802 136 addIPField(20+65+65, ButtonGw0, "Gateway:");
embeddedartists 13:57e65aba9802 137
embeddedartists 18:715f542538b3 138 // Restore shared image so that it will be deallocated during teardown
embeddedartists 18:715f542538b3 139 _digitImage.pointerToFree = pointerToFree;
embeddedartists 18:715f542538b3 140
embeddedartists 13:57e65aba9802 141 for (int i = 0; i < NumButtons; i++) {
embeddedartists 13:57e65aba9802 142 _buttons[i]->draw();
embeddedartists 13:57e65aba9802 143 }
embeddedartists 13:57e65aba9802 144
embeddedartists 13:57e65aba9802 145 markField(_activeField, true);
embeddedartists 13:57e65aba9802 146 }
embeddedartists 13:57e65aba9802 147
embeddedartists 13:57e65aba9802 148 void AppNetworkSettings::addIPField(int y, int idx, const char* lbl)
embeddedartists 13:57e65aba9802 149 {
embeddedartists 13:57e65aba9802 150 DigitButton* db;
embeddedartists 13:57e65aba9802 151
embeddedartists 13:57e65aba9802 152 swim_put_text_xy(_win, lbl, 10, y);
embeddedartists 13:57e65aba9802 153 y += 15;
embeddedartists 13:57e65aba9802 154 int btny = y-7;
embeddedartists 13:57e65aba9802 155 y += _win->ypvmin; // compensate for title bar
embeddedartists 13:57e65aba9802 156 int x = 20;
embeddedartists 13:57e65aba9802 157
embeddedartists 13:57e65aba9802 158
embeddedartists 13:57e65aba9802 159 db = new DigitButton(_win->fb, x, y, 55, 34);
embeddedartists 18:715f542538b3 160 db->loadImages(&_digitImage);//img_numbers, img_size_numbers);
embeddedartists 13:57e65aba9802 161 db->setNumDigits(3);
embeddedartists 13:57e65aba9802 162 db->setValue(_values[idx]);
embeddedartists 13:57e65aba9802 163 db->setAction(fieldClicked, idx);
embeddedartists 13:57e65aba9802 164 _buttons[idx++] = db;
embeddedartists 13:57e65aba9802 165
embeddedartists 13:57e65aba9802 166 x += 60;
embeddedartists 13:57e65aba9802 167 db = new DigitButton(_win->fb, x, y, 55, 34);
embeddedartists 18:715f542538b3 168 db->loadImages(&_digitImage);//img_numbers, img_size_numbers);
embeddedartists 13:57e65aba9802 169 db->setNumDigits(3);
embeddedartists 13:57e65aba9802 170 db->setValue(_values[idx]);
embeddedartists 13:57e65aba9802 171 db->setAction(fieldClicked, idx);
embeddedartists 13:57e65aba9802 172 _buttons[idx++] = db;
embeddedartists 13:57e65aba9802 173 swim_put_box(_win, x-7, btny+31, x-4, btny+34);
embeddedartists 13:57e65aba9802 174
embeddedartists 13:57e65aba9802 175 x += 60;
embeddedartists 13:57e65aba9802 176 db = new DigitButton(_win->fb, x, y, 55, 34);
embeddedartists 18:715f542538b3 177 db->loadImages(&_digitImage);//img_numbers, img_size_numbers);
embeddedartists 13:57e65aba9802 178 db->setNumDigits(3);
embeddedartists 13:57e65aba9802 179 db->setValue(_values[idx]);
embeddedartists 13:57e65aba9802 180 db->setAction(fieldClicked, idx);
embeddedartists 13:57e65aba9802 181 _buttons[idx++] = db;
embeddedartists 13:57e65aba9802 182 swim_put_box(_win, x-7, btny+31, x-4, btny+34);
embeddedartists 13:57e65aba9802 183
embeddedartists 13:57e65aba9802 184 x += 60;
embeddedartists 13:57e65aba9802 185 db = new DigitButton(_win->fb, x, y, 55, 34);
embeddedartists 18:715f542538b3 186 db->loadImages(&_digitImage);//img_numbers, img_size_numbers);
embeddedartists 13:57e65aba9802 187 db->setNumDigits(3);
embeddedartists 13:57e65aba9802 188 db->setValue(_values[idx]);
embeddedartists 13:57e65aba9802 189 db->setAction(fieldClicked, idx);
embeddedartists 13:57e65aba9802 190 _buttons[idx++] = db;
embeddedartists 13:57e65aba9802 191 swim_put_box(_win, x-7, btny+31, x-4, btny+34);
embeddedartists 13:57e65aba9802 192 }
embeddedartists 13:57e65aba9802 193
embeddedartists 13:57e65aba9802 194 void AppNetworkSettings::markField(int field, bool active)
embeddedartists 13:57e65aba9802 195 {
embeddedartists 13:57e65aba9802 196 COLOR_T oldPen = _win->pen;
embeddedartists 13:57e65aba9802 197 COLOR_T oldFill = _win->fill;
embeddedartists 13:57e65aba9802 198 _win->fill = active ? BLACK : _win->bkg;
embeddedartists 13:57e65aba9802 199 _win->pen = active ? BLACK : _win->bkg;
embeddedartists 13:57e65aba9802 200 if (field >= 0 && field < NumFields) {
embeddedartists 13:57e65aba9802 201 int x0, y0, x1, y1;
embeddedartists 13:57e65aba9802 202 _buttons[field]->bounds(x0,y0,x1,y1);
embeddedartists 13:57e65aba9802 203 y1 -= _win->ypvmin+1;
embeddedartists 13:57e65aba9802 204 x0--;
embeddedartists 13:57e65aba9802 205 swim_put_box(_win, x0, y1, x1, y1+3);
embeddedartists 13:57e65aba9802 206 }
embeddedartists 13:57e65aba9802 207 _win->fill = oldFill;
embeddedartists 13:57e65aba9802 208 _win->pen = oldPen;
embeddedartists 13:57e65aba9802 209 }
embeddedartists 13:57e65aba9802 210
embeddedartists 13:57e65aba9802 211 /******************************************************************************
embeddedartists 13:57e65aba9802 212 * Public functions
embeddedartists 13:57e65aba9802 213 *****************************************************************************/
embeddedartists 13:57e65aba9802 214
embeddedartists 13:57e65aba9802 215 AppNetworkSettings::AppNetworkSettings() : _disp(NULL), _win(NULL), _fb(NULL), _activeField(0)
embeddedartists 13:57e65aba9802 216 {
embeddedartists 13:57e65aba9802 217 for (int i = 0; i < NumButtons; i++) {
embeddedartists 13:57e65aba9802 218 _buttons[i] = NULL;
embeddedartists 13:57e65aba9802 219 }
embeddedartists 13:57e65aba9802 220 _values[0] = 192;
embeddedartists 13:57e65aba9802 221 _values[1] = 168;
embeddedartists 13:57e65aba9802 222 _values[2] = 5;
embeddedartists 13:57e65aba9802 223 _values[3] = 220;
embeddedartists 13:57e65aba9802 224 _values[4] = 255;
embeddedartists 13:57e65aba9802 225 _values[5] = 255;
embeddedartists 13:57e65aba9802 226 _values[6] = 255;
embeddedartists 13:57e65aba9802 227 _values[7] = 0;
embeddedartists 13:57e65aba9802 228 _values[8] = 192;
embeddedartists 13:57e65aba9802 229 _values[9] = 168;
embeddedartists 13:57e65aba9802 230 _values[10] = 5;
embeddedartists 13:57e65aba9802 231 _values[11] = 1;
embeddedartists 13:57e65aba9802 232
embeddedartists 18:715f542538b3 233 _digitImage.pointerToFree = NULL;
embeddedartists 18:715f542538b3 234
embeddedartists 13:57e65aba9802 235 theApp = this;
embeddedartists 13:57e65aba9802 236 }
embeddedartists 13:57e65aba9802 237
embeddedartists 13:57e65aba9802 238 AppNetworkSettings::~AppNetworkSettings()
embeddedartists 13:57e65aba9802 239 {
embeddedartists 13:57e65aba9802 240 theApp = NULL;
embeddedartists 13:57e65aba9802 241 teardown();
embeddedartists 13:57e65aba9802 242 }
embeddedartists 13:57e65aba9802 243
embeddedartists 13:57e65aba9802 244 bool AppNetworkSettings::setup()
embeddedartists 13:57e65aba9802 245 {
embeddedartists 13:57e65aba9802 246 _disp = DMBoard::instance().display();
embeddedartists 13:57e65aba9802 247 _win = (SWIM_WINDOW_T*)malloc(sizeof(SWIM_WINDOW_T));
embeddedartists 13:57e65aba9802 248 _fb = _disp->allocateFramebuffer();
embeddedartists 18:715f542538b3 249 int res = Image::decode(img_numbers, img_size_numbers, Image::RES_16BIT, &_digitImage);
embeddedartists 13:57e65aba9802 250
embeddedartists 18:715f542538b3 251 return (_win != NULL && _fb != NULL && res == 0);
embeddedartists 13:57e65aba9802 252 }
embeddedartists 13:57e65aba9802 253
embeddedartists 13:57e65aba9802 254 void AppNetworkSettings::runToCompletion()
embeddedartists 13:57e65aba9802 255 {
embeddedartists 13:57e65aba9802 256 // Alternative 1: use the calling thread's context to run in
embeddedartists 13:57e65aba9802 257 bool done = false;
embeddedartists 13:57e65aba9802 258 bool abort = false;
embeddedartists 13:57e65aba9802 259 draw();
embeddedartists 13:57e65aba9802 260 _buttons[ButtonOk]->setAction(buttonClicked, (uint32_t)&done);
embeddedartists 13:57e65aba9802 261 _buttons[ButtonCancel]->setAction(buttonClicked, (uint32_t)&abort);
embeddedartists 13:57e65aba9802 262 void* oldFB = _disp->swapFramebuffer(_fb);
embeddedartists 13:57e65aba9802 263
embeddedartists 13:57e65aba9802 264 // Wait for touches
embeddedartists 13:57e65aba9802 265 TouchPanel* touch = DMBoard::instance().touchPanel();
embeddedartists 16:77f4f42eb6a7 266 touch_coordinate_t coord;
embeddedartists 13:57e65aba9802 267
embeddedartists 13:57e65aba9802 268 int lastPressed = NumButtons;
embeddedartists 13:57e65aba9802 269 Timer t;
embeddedartists 13:57e65aba9802 270 t.start();
alindvall 27:4fe24decabf9 271 int repeatAt = 0;
embeddedartists 16:77f4f42eb6a7 272
embeddedartists 16:77f4f42eb6a7 273 uint32_t maxDelay = osWaitForever;
embeddedartists 13:57e65aba9802 274 while(!done && !abort) {
embeddedartists 30:e1cded731965 275 ThisThread::flags_wait_all(0x1, maxDelay);
embeddedartists 13:57e65aba9802 276 if (touch->read(coord) == TouchPanel::TouchError_Ok) {
embeddedartists 13:57e65aba9802 277 for (int i = 0; i < NumButtons; i++) {
embeddedartists 13:57e65aba9802 278 if (_buttons[i]->handle(coord.x, coord.y, coord.z > 0)) {
embeddedartists 13:57e65aba9802 279 _buttons[i]->draw();
embeddedartists 13:57e65aba9802 280 if (_buttons[i]->pressed()) {
embeddedartists 13:57e65aba9802 281 lastPressed = i; // new button pressed
embeddedartists 13:57e65aba9802 282 t.reset();
embeddedartists 13:57e65aba9802 283 repeatAt = 1000;
embeddedartists 13:57e65aba9802 284 }
embeddedartists 13:57e65aba9802 285 }
embeddedartists 13:57e65aba9802 286 }
embeddedartists 13:57e65aba9802 287 if (lastPressed == ButtonUp || lastPressed == ButtonDown) {
embeddedartists 16:77f4f42eb6a7 288 maxDelay = 10;
embeddedartists 13:57e65aba9802 289 if (_buttons[lastPressed]->pressed() && t.read_ms() > repeatAt) {
embeddedartists 13:57e65aba9802 290 modifyValue((lastPressed == ButtonUp) ? 1 : -1);
embeddedartists 13:57e65aba9802 291 repeatAt = t.read_ms()+(200/(t.read_ms()/1000));
embeddedartists 13:57e65aba9802 292 }
embeddedartists 16:77f4f42eb6a7 293 } else {
embeddedartists 16:77f4f42eb6a7 294 maxDelay = osWaitForever;
embeddedartists 13:57e65aba9802 295 }
embeddedartists 13:57e65aba9802 296 }
embeddedartists 13:57e65aba9802 297 }
embeddedartists 13:57e65aba9802 298
embeddedartists 13:57e65aba9802 299 if (!abort) {
embeddedartists 14:73f6c425b2b5 300 #if defined(DM_BOARD_USE_REGISTRY)
embeddedartists 14:73f6c425b2b5 301 Registry* reg = DMBoard::instance().registry();
embeddedartists 14:73f6c425b2b5 302 RtosLog* log = DMBoard::instance().logger();
embeddedartists 14:73f6c425b2b5 303 char buf[16] = {0};
embeddedartists 30:e1cded731965 304 sprintf(buf, "%u.%u.%u.%u", _values[0], _values[1], _values[2], _values[3]);
embeddedartists 14:73f6c425b2b5 305 reg->setValue("IP Address", buf);
embeddedartists 14:73f6c425b2b5 306 log->printf("New STATIC IP Address: %s\n", buf);
embeddedartists 30:e1cded731965 307 sprintf(buf, "%u.%u.%u.%u", _values[4], _values[5], _values[6], _values[7]);
embeddedartists 14:73f6c425b2b5 308 reg->setValue("Net Mask", buf);
embeddedartists 14:73f6c425b2b5 309 log->printf("New STATIC Net Mask: %s\n", buf);
embeddedartists 30:e1cded731965 310 sprintf(buf, "%u.%u.%u.%u", _values[8], _values[9], _values[10], _values[11]);
embeddedartists 14:73f6c425b2b5 311 reg->setValue("Gateway", buf);
embeddedartists 14:73f6c425b2b5 312 log->printf("New STATIC Gateway: %s\n", buf);
embeddedartists 14:73f6c425b2b5 313 reg->store();
embeddedartists 14:73f6c425b2b5 314 #endif
embeddedartists 13:57e65aba9802 315 }
embeddedartists 13:57e65aba9802 316
embeddedartists 13:57e65aba9802 317 // User has clicked the button, restore the original FB
embeddedartists 13:57e65aba9802 318 _disp->swapFramebuffer(oldFB);
embeddedartists 13:57e65aba9802 319 swim_window_close(_win);
embeddedartists 13:57e65aba9802 320 }
embeddedartists 13:57e65aba9802 321
embeddedartists 13:57e65aba9802 322 bool AppNetworkSettings::teardown()
embeddedartists 13:57e65aba9802 323 {
embeddedartists 13:57e65aba9802 324 if (_win != NULL) {
embeddedartists 13:57e65aba9802 325 free(_win);
embeddedartists 13:57e65aba9802 326 _win = NULL;
embeddedartists 13:57e65aba9802 327 }
embeddedartists 13:57e65aba9802 328 if (_fb != NULL) {
embeddedartists 13:57e65aba9802 329 free(_fb);
embeddedartists 13:57e65aba9802 330 _fb = NULL;
embeddedartists 13:57e65aba9802 331 }
embeddedartists 13:57e65aba9802 332 for (int i = 0; i < NumButtons; i++) {
embeddedartists 13:57e65aba9802 333 if (_buttons[i] != NULL) {
embeddedartists 13:57e65aba9802 334 delete _buttons[i];
embeddedartists 13:57e65aba9802 335 _buttons[i] = NULL;
embeddedartists 13:57e65aba9802 336 }
embeddedartists 13:57e65aba9802 337 }
embeddedartists 18:715f542538b3 338 if (_digitImage.pointerToFree != NULL) {
embeddedartists 18:715f542538b3 339 free(_digitImage.pointerToFree);
embeddedartists 18:715f542538b3 340 _digitImage.pointerToFree = NULL;
embeddedartists 18:715f542538b3 341 }
embeddedartists 13:57e65aba9802 342 return true;
embeddedartists 13:57e65aba9802 343 }
embeddedartists 13:57e65aba9802 344
embeddedartists 13:57e65aba9802 345 void AppNetworkSettings::modifyValue(int mod)
embeddedartists 13:57e65aba9802 346 {
embeddedartists 13:57e65aba9802 347 _values[_activeField] = (mod + _values[_activeField]) % 256;
embeddedartists 13:57e65aba9802 348 ((DigitButton*)_buttons[_activeField])->setValue(_values[_activeField]);
embeddedartists 13:57e65aba9802 349 }
embeddedartists 13:57e65aba9802 350
embeddedartists 13:57e65aba9802 351 void AppNetworkSettings::changeActiveField(bool next)
embeddedartists 13:57e65aba9802 352 {
embeddedartists 13:57e65aba9802 353 markField(_activeField, false);
embeddedartists 13:57e65aba9802 354 if (next) {
embeddedartists 13:57e65aba9802 355 _activeField = (_activeField+1) % NumFields;
embeddedartists 13:57e65aba9802 356 } else {
embeddedartists 13:57e65aba9802 357 _activeField = (_activeField+NumFields-1) % NumFields;
embeddedartists 13:57e65aba9802 358 }
embeddedartists 13:57e65aba9802 359 markField(_activeField, true);
embeddedartists 13:57e65aba9802 360 }
embeddedartists 13:57e65aba9802 361
embeddedartists 13:57e65aba9802 362 void AppNetworkSettings::setActiveField(uint32_t newField)
embeddedartists 13:57e65aba9802 363 {
embeddedartists 13:57e65aba9802 364 if (_activeField != newField && newField < NumFields) {
embeddedartists 13:57e65aba9802 365 markField(_activeField, false);
embeddedartists 13:57e65aba9802 366 _activeField = newField;
embeddedartists 13:57e65aba9802 367 markField(_activeField, true);
embeddedartists 13:57e65aba9802 368 }
embeddedartists 13:57e65aba9802 369 }