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 Jan 12 10:36:07 2015 +0100
Revision:
14:73f6c425b2b5
Parent:
13:57e65aba9802
Child:
16:77f4f42eb6a7
- Added test of the new Registry class

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 13:57e65aba9802 130 addIPField(20, ButtonIp0, "IP Address:");
embeddedartists 13:57e65aba9802 131 addIPField(20+65, ButtonMask0, "Net Mask:");
embeddedartists 13:57e65aba9802 132 addIPField(20+65+65, ButtonGw0, "Gateway:");
embeddedartists 13:57e65aba9802 133
embeddedartists 13:57e65aba9802 134 for (int i = 0; i < NumButtons; i++) {
embeddedartists 13:57e65aba9802 135 _buttons[i]->draw();
embeddedartists 13:57e65aba9802 136 }
embeddedartists 13:57e65aba9802 137
embeddedartists 13:57e65aba9802 138 markField(_activeField, true);
embeddedartists 13:57e65aba9802 139 }
embeddedartists 13:57e65aba9802 140
embeddedartists 13:57e65aba9802 141 void AppNetworkSettings::addIPField(int y, int idx, const char* lbl)
embeddedartists 13:57e65aba9802 142 {
embeddedartists 13:57e65aba9802 143 DigitButton* db;
embeddedartists 13:57e65aba9802 144
embeddedartists 13:57e65aba9802 145 swim_put_text_xy(_win, lbl, 10, y);
embeddedartists 13:57e65aba9802 146 y += 15;
embeddedartists 13:57e65aba9802 147 int btny = y-7;
embeddedartists 13:57e65aba9802 148 y += _win->ypvmin; // compensate for title bar
embeddedartists 13:57e65aba9802 149 int x = 20;
embeddedartists 13:57e65aba9802 150
embeddedartists 13:57e65aba9802 151
embeddedartists 13:57e65aba9802 152 db = new DigitButton(_win->fb, x, y, 55, 34);
embeddedartists 13:57e65aba9802 153 db->loadImages(img_numbers, img_size_numbers);
embeddedartists 13:57e65aba9802 154 db->setNumDigits(3);
embeddedartists 13:57e65aba9802 155 db->setValue(_values[idx]);
embeddedartists 13:57e65aba9802 156 db->setAction(fieldClicked, idx);
embeddedartists 13:57e65aba9802 157 _buttons[idx++] = db;
embeddedartists 13:57e65aba9802 158
embeddedartists 13:57e65aba9802 159 x += 60;
embeddedartists 13:57e65aba9802 160 db = new DigitButton(_win->fb, x, y, 55, 34);
embeddedartists 13:57e65aba9802 161 db->loadImages(img_numbers, img_size_numbers);
embeddedartists 13:57e65aba9802 162 db->setNumDigits(3);
embeddedartists 13:57e65aba9802 163 db->setValue(_values[idx]);
embeddedartists 13:57e65aba9802 164 db->setAction(fieldClicked, idx);
embeddedartists 13:57e65aba9802 165 _buttons[idx++] = db;
embeddedartists 13:57e65aba9802 166 swim_put_box(_win, x-7, btny+31, x-4, btny+34);
embeddedartists 13:57e65aba9802 167
embeddedartists 13:57e65aba9802 168 x += 60;
embeddedartists 13:57e65aba9802 169 db = new DigitButton(_win->fb, x, y, 55, 34);
embeddedartists 13:57e65aba9802 170 db->loadImages(img_numbers, img_size_numbers);
embeddedartists 13:57e65aba9802 171 db->setNumDigits(3);
embeddedartists 13:57e65aba9802 172 db->setValue(_values[idx]);
embeddedartists 13:57e65aba9802 173 db->setAction(fieldClicked, idx);
embeddedartists 13:57e65aba9802 174 _buttons[idx++] = db;
embeddedartists 13:57e65aba9802 175 swim_put_box(_win, x-7, btny+31, x-4, btny+34);
embeddedartists 13:57e65aba9802 176
embeddedartists 13:57e65aba9802 177 x += 60;
embeddedartists 13:57e65aba9802 178 db = new DigitButton(_win->fb, x, y, 55, 34);
embeddedartists 13:57e65aba9802 179 db->loadImages(img_numbers, img_size_numbers);
embeddedartists 13:57e65aba9802 180 db->setNumDigits(3);
embeddedartists 13:57e65aba9802 181 db->setValue(_values[idx]);
embeddedartists 13:57e65aba9802 182 db->setAction(fieldClicked, idx);
embeddedartists 13:57e65aba9802 183 _buttons[idx++] = db;
embeddedartists 13:57e65aba9802 184 swim_put_box(_win, x-7, btny+31, x-4, btny+34);
embeddedartists 13:57e65aba9802 185 }
embeddedartists 13:57e65aba9802 186
embeddedartists 13:57e65aba9802 187 void AppNetworkSettings::markField(int field, bool active)
embeddedartists 13:57e65aba9802 188 {
embeddedartists 13:57e65aba9802 189 COLOR_T oldPen = _win->pen;
embeddedartists 13:57e65aba9802 190 COLOR_T oldFill = _win->fill;
embeddedartists 13:57e65aba9802 191 _win->fill = active ? BLACK : _win->bkg;
embeddedartists 13:57e65aba9802 192 _win->pen = active ? BLACK : _win->bkg;
embeddedartists 13:57e65aba9802 193 if (field >= 0 && field < NumFields) {
embeddedartists 13:57e65aba9802 194 int x0, y0, x1, y1;
embeddedartists 13:57e65aba9802 195 _buttons[field]->bounds(x0,y0,x1,y1);
embeddedartists 13:57e65aba9802 196 y1 -= _win->ypvmin+1;
embeddedartists 13:57e65aba9802 197 x0--;
embeddedartists 13:57e65aba9802 198 swim_put_box(_win, x0, y1, x1, y1+3);
embeddedartists 13:57e65aba9802 199 }
embeddedartists 13:57e65aba9802 200 _win->fill = oldFill;
embeddedartists 13:57e65aba9802 201 _win->pen = oldPen;
embeddedartists 13:57e65aba9802 202 }
embeddedartists 13:57e65aba9802 203
embeddedartists 13:57e65aba9802 204 /******************************************************************************
embeddedartists 13:57e65aba9802 205 * Public functions
embeddedartists 13:57e65aba9802 206 *****************************************************************************/
embeddedartists 13:57e65aba9802 207
embeddedartists 13:57e65aba9802 208 AppNetworkSettings::AppNetworkSettings() : _disp(NULL), _win(NULL), _fb(NULL), _activeField(0)
embeddedartists 13:57e65aba9802 209 {
embeddedartists 13:57e65aba9802 210 for (int i = 0; i < NumButtons; i++) {
embeddedartists 13:57e65aba9802 211 _buttons[i] = NULL;
embeddedartists 13:57e65aba9802 212 }
embeddedartists 13:57e65aba9802 213 _values[0] = 192;
embeddedartists 13:57e65aba9802 214 _values[1] = 168;
embeddedartists 13:57e65aba9802 215 _values[2] = 5;
embeddedartists 13:57e65aba9802 216 _values[3] = 220;
embeddedartists 13:57e65aba9802 217 _values[4] = 255;
embeddedartists 13:57e65aba9802 218 _values[5] = 255;
embeddedartists 13:57e65aba9802 219 _values[6] = 255;
embeddedartists 13:57e65aba9802 220 _values[7] = 0;
embeddedartists 13:57e65aba9802 221 _values[8] = 192;
embeddedartists 13:57e65aba9802 222 _values[9] = 168;
embeddedartists 13:57e65aba9802 223 _values[10] = 5;
embeddedartists 13:57e65aba9802 224 _values[11] = 1;
embeddedartists 13:57e65aba9802 225
embeddedartists 13:57e65aba9802 226 theApp = this;
embeddedartists 13:57e65aba9802 227 }
embeddedartists 13:57e65aba9802 228
embeddedartists 13:57e65aba9802 229 AppNetworkSettings::~AppNetworkSettings()
embeddedartists 13:57e65aba9802 230 {
embeddedartists 13:57e65aba9802 231 theApp = NULL;
embeddedartists 13:57e65aba9802 232 teardown();
embeddedartists 13:57e65aba9802 233 }
embeddedartists 13:57e65aba9802 234
embeddedartists 13:57e65aba9802 235 bool AppNetworkSettings::setup()
embeddedartists 13:57e65aba9802 236 {
embeddedartists 13:57e65aba9802 237 _disp = DMBoard::instance().display();
embeddedartists 13:57e65aba9802 238 _win = (SWIM_WINDOW_T*)malloc(sizeof(SWIM_WINDOW_T));
embeddedartists 13:57e65aba9802 239 _fb = _disp->allocateFramebuffer();
embeddedartists 13:57e65aba9802 240
embeddedartists 13:57e65aba9802 241 return (_win != NULL && _fb != NULL);
embeddedartists 13:57e65aba9802 242 }
embeddedartists 13:57e65aba9802 243
embeddedartists 13:57e65aba9802 244 void AppNetworkSettings::runToCompletion()
embeddedartists 13:57e65aba9802 245 {
embeddedartists 13:57e65aba9802 246 // Alternative 1: use the calling thread's context to run in
embeddedartists 13:57e65aba9802 247 bool done = false;
embeddedartists 13:57e65aba9802 248 bool abort = false;
embeddedartists 13:57e65aba9802 249 draw();
embeddedartists 13:57e65aba9802 250 _buttons[ButtonOk]->setAction(buttonClicked, (uint32_t)&done);
embeddedartists 13:57e65aba9802 251 _buttons[ButtonCancel]->setAction(buttonClicked, (uint32_t)&abort);
embeddedartists 13:57e65aba9802 252 void* oldFB = _disp->swapFramebuffer(_fb);
embeddedartists 13:57e65aba9802 253
embeddedartists 13:57e65aba9802 254 // Wait for touches
embeddedartists 13:57e65aba9802 255 TouchPanel* touch = DMBoard::instance().touchPanel();
embeddedartists 13:57e65aba9802 256 TouchPanel::touchCoordinate_t coord;
embeddedartists 13:57e65aba9802 257
embeddedartists 13:57e65aba9802 258 int lastPressed = NumButtons;
embeddedartists 13:57e65aba9802 259 Timer t;
embeddedartists 13:57e65aba9802 260 t.start();
embeddedartists 13:57e65aba9802 261 uint32_t repeatAt;
embeddedartists 13:57e65aba9802 262 while(!done && !abort) {
embeddedartists 13:57e65aba9802 263 if (touch->read(coord) == TouchPanel::TouchError_Ok) {
embeddedartists 13:57e65aba9802 264 for (int i = 0; i < NumButtons; i++) {
embeddedartists 13:57e65aba9802 265 if (_buttons[i]->handle(coord.x, coord.y, coord.z > 0)) {
embeddedartists 13:57e65aba9802 266 _buttons[i]->draw();
embeddedartists 13:57e65aba9802 267 if (_buttons[i]->pressed()) {
embeddedartists 13:57e65aba9802 268 lastPressed = i; // new button pressed
embeddedartists 13:57e65aba9802 269 t.reset();
embeddedartists 13:57e65aba9802 270 repeatAt = 1000;
embeddedartists 13:57e65aba9802 271 }
embeddedartists 13:57e65aba9802 272 }
embeddedartists 13:57e65aba9802 273 }
embeddedartists 13:57e65aba9802 274 if (lastPressed == ButtonUp || lastPressed == ButtonDown) {
embeddedartists 13:57e65aba9802 275 if (_buttons[lastPressed]->pressed() && t.read_ms() > repeatAt) {
embeddedartists 13:57e65aba9802 276 modifyValue((lastPressed == ButtonUp) ? 1 : -1);
embeddedartists 13:57e65aba9802 277 repeatAt = t.read_ms()+(200/(t.read_ms()/1000));
embeddedartists 13:57e65aba9802 278 }
embeddedartists 13:57e65aba9802 279 }
embeddedartists 13:57e65aba9802 280 }
embeddedartists 13:57e65aba9802 281 }
embeddedartists 13:57e65aba9802 282
embeddedartists 13:57e65aba9802 283 if (!abort) {
embeddedartists 14:73f6c425b2b5 284 #if defined(DM_BOARD_USE_REGISTRY)
embeddedartists 14:73f6c425b2b5 285 Registry* reg = DMBoard::instance().registry();
embeddedartists 14:73f6c425b2b5 286 RtosLog* log = DMBoard::instance().logger();
embeddedartists 14:73f6c425b2b5 287 char buf[16] = {0};
embeddedartists 14:73f6c425b2b5 288 sprintf(buf, "%d.%d.%d.%d", _values[0], _values[1], _values[2], _values[3]);
embeddedartists 14:73f6c425b2b5 289 reg->setValue("IP Address", buf);
embeddedartists 14:73f6c425b2b5 290 log->printf("New STATIC IP Address: %s\n", buf);
embeddedartists 14:73f6c425b2b5 291 sprintf(buf, "%d.%d.%d.%d", _values[4], _values[5], _values[6], _values[7]);
embeddedartists 14:73f6c425b2b5 292 reg->setValue("Net Mask", buf);
embeddedartists 14:73f6c425b2b5 293 log->printf("New STATIC Net Mask: %s\n", buf);
embeddedartists 14:73f6c425b2b5 294 sprintf(buf, "%d.%d.%d.%d", _values[8], _values[9], _values[10], _values[11]);
embeddedartists 14:73f6c425b2b5 295 reg->setValue("Gateway", buf);
embeddedartists 14:73f6c425b2b5 296 log->printf("New STATIC Gateway: %s\n", buf);
embeddedartists 14:73f6c425b2b5 297 reg->store();
embeddedartists 14:73f6c425b2b5 298 #endif
embeddedartists 13:57e65aba9802 299 }
embeddedartists 13:57e65aba9802 300
embeddedartists 13:57e65aba9802 301 // User has clicked the button, restore the original FB
embeddedartists 13:57e65aba9802 302 _disp->swapFramebuffer(oldFB);
embeddedartists 13:57e65aba9802 303 swim_window_close(_win);
embeddedartists 13:57e65aba9802 304 }
embeddedartists 13:57e65aba9802 305
embeddedartists 13:57e65aba9802 306 bool AppNetworkSettings::teardown()
embeddedartists 13:57e65aba9802 307 {
embeddedartists 13:57e65aba9802 308 if (_win != NULL) {
embeddedartists 13:57e65aba9802 309 free(_win);
embeddedartists 13:57e65aba9802 310 _win = NULL;
embeddedartists 13:57e65aba9802 311 }
embeddedartists 13:57e65aba9802 312 if (_fb != NULL) {
embeddedartists 13:57e65aba9802 313 free(_fb);
embeddedartists 13:57e65aba9802 314 _fb = NULL;
embeddedartists 13:57e65aba9802 315 }
embeddedartists 13:57e65aba9802 316 for (int i = 0; i < NumButtons; i++) {
embeddedartists 13:57e65aba9802 317 if (_buttons[i] != NULL) {
embeddedartists 13:57e65aba9802 318 delete _buttons[i];
embeddedartists 13:57e65aba9802 319 _buttons[i] = NULL;
embeddedartists 13:57e65aba9802 320 }
embeddedartists 13:57e65aba9802 321 }
embeddedartists 13:57e65aba9802 322 return true;
embeddedartists 13:57e65aba9802 323 }
embeddedartists 13:57e65aba9802 324
embeddedartists 13:57e65aba9802 325 void AppNetworkSettings::modifyValue(int mod)
embeddedartists 13:57e65aba9802 326 {
embeddedartists 13:57e65aba9802 327 _values[_activeField] = (mod + _values[_activeField]) % 256;
embeddedartists 13:57e65aba9802 328 ((DigitButton*)_buttons[_activeField])->setValue(_values[_activeField]);
embeddedartists 13:57e65aba9802 329 }
embeddedartists 13:57e65aba9802 330
embeddedartists 13:57e65aba9802 331 void AppNetworkSettings::changeActiveField(bool next)
embeddedartists 13:57e65aba9802 332 {
embeddedartists 13:57e65aba9802 333 markField(_activeField, false);
embeddedartists 13:57e65aba9802 334 if (next) {
embeddedartists 13:57e65aba9802 335 _activeField = (_activeField+1) % NumFields;
embeddedartists 13:57e65aba9802 336 } else {
embeddedartists 13:57e65aba9802 337 _activeField = (_activeField+NumFields-1) % NumFields;
embeddedartists 13:57e65aba9802 338 }
embeddedartists 13:57e65aba9802 339 markField(_activeField, true);
embeddedartists 13:57e65aba9802 340 }
embeddedartists 13:57e65aba9802 341
embeddedartists 13:57e65aba9802 342 void AppNetworkSettings::setActiveField(uint32_t newField)
embeddedartists 13:57e65aba9802 343 {
embeddedartists 13:57e65aba9802 344 if (_activeField != newField && newField < NumFields) {
embeddedartists 13:57e65aba9802 345 markField(_activeField, false);
embeddedartists 13:57e65aba9802 346 _activeField = newField;
embeddedartists 13:57e65aba9802 347 markField(_activeField, true);
embeddedartists 13:57e65aba9802 348 }
embeddedartists 13:57e65aba9802 349 }