Augustine Kizito / Mbed 2 deprecated Solar_Powered_Smart_Camera

Dependencies:   Adafruit_GFX Adafruit_ST7735 INA219 MODSERIAL MbedJSONValue mbed-rtos mbed

Committer:
OHstin
Date:
Sat Feb 04 20:17:44 2017 +0000
Revision:
3:7666de697752
Parent:
2:104bec169fb6
Child:
4:c7b0670f96b2
This version before adding serial communication and pathways

Who changed what in which revision?

UserRevisionLine numberNew contents of line
OHstin 0:5139f11cfc62 1 #include "mbed.h"
OHstin 3:7666de697752 2 #include "rtos.h"
OHstin 3:7666de697752 3 #include "MbedJSONValue.h"
OHstin 3:7666de697752 4 #include <string>
OHstin 0:5139f11cfc62 5 #include "Adafruit_ST7735.h"
OHstin 3:7666de697752 6 #include "SensorSuite.h"
OHstin 3:7666de697752 7
OHstin 0:5139f11cfc62 8
OHstin 3:7666de697752 9 DigitalOut myled(LED1);
OHstin 3:7666de697752 10 DigitalOut myled2(LED2);
OHstin 3:7666de697752 11 DigitalOut relayOne(p26);
OHstin 3:7666de697752 12 DigitalOut relayTwo(p25);
OHstin 3:7666de697752 13 DigitalOut relayThree(p24);
OHstin 3:7666de697752 14
OHstin 3:7666de697752 15 #define OFF 1
OHstin 3:7666de697752 16 #define ON 0
OHstin 3:7666de697752 17
OHstin 3:7666de697752 18
OHstin 3:7666de697752 19
OHstin 3:7666de697752 20
OHstin 3:7666de697752 21 uint16_t backgroundColor = ST7735_BLACK;
OHstin 0:5139f11cfc62 22
OHstin 1:1354a7ebd0c6 23
OHstin 3:7666de697752 24 LocalFileSystem local("local");
OHstin 0:5139f11cfc62 25
OHstin 3:7666de697752 26 //Adafruit_ST7735 tft(p11, p12, p13, p10, p8, p9); // MOSI, MISO, SCLK, SSEL, TFT_DC, TFT_RST
OHstin 3:7666de697752 27 Adafruit_ST7735 tft(p11, p12, p13, p16, p14, p15); // MOSI, MISO, SCLK, SSEL, TFT_DC, TFT_RST
OHstin 3:7666de697752 28 #include "Icons.h"
OHstin 3:7666de697752 29 #include "Inputs.h"
OHstin 3:7666de697752 30 #include "Settings.h"
OHstin 3:7666de697752 31 #include "SettingsTest.h"
OHstin 3:7666de697752 32 #include "LogManager.h"
OHstin 3:7666de697752 33 #include "LogRecord.h"
OHstin 3:7666de697752 34 #include "Screens.h"
OHstin 3:7666de697752 35 #include "RaspiSerial.h"
OHstin 0:5139f11cfc62 36
OHstin 0:5139f11cfc62 37
OHstin 3:7666de697752 38 void createScreens();
OHstin 3:7666de697752 39 void changeBackgroundColor();
OHstin 3:7666de697752 40 bool settingsExist( const char *fname);
OHstin 3:7666de697752 41 void uiThread();
OHstin 3:7666de697752 42 void sensorThread();
OHstin 3:7666de697752 43
OHstin 3:7666de697752 44 uint16_t currentColor;
OHstin 0:5139f11cfc62 45
OHstin 3:7666de697752 46 // ensure that settings are not initialised
OHstin 3:7666de697752 47 bool Settings::settingsInitialised = false;
OHstin 3:7666de697752 48 MbedJSONValue Settings:: holder; // JSON Data structure to store settings read from file
OHstin 3:7666de697752 49 uint16_t Settings::backgroundColor = 0;
OHstin 1:1354a7ebd0c6 50
OHstin 3:7666de697752 51 // ensure that sensor data is initialised
OHstin 3:7666de697752 52
OHstin 3:7666de697752 53
OHstin 1:1354a7ebd0c6 54
OHstin 3:7666de697752 55 MainMenuScreen *menu;
OHstin 3:7666de697752 56 BatteriesScreen *batteriesScreen;
OHstin 3:7666de697752 57 BatteryScreen *battScreen;
OHstin 3:7666de697752 58 SolarScreen *solarScreen;
OHstin 3:7666de697752 59 OutputScreen *outputScreen;
OHstin 3:7666de697752 60 SettingsScreen *settingsScreen;
OHstin 3:7666de697752 61 SolarGraphScreen *solarGraphScreen;
OHstin 3:7666de697752 62 SolarValueScreen *solarValueScreen;
OHstin 3:7666de697752 63 TestScreen *test;
OHstin 3:7666de697752 64 LogScreen *logg;
OHstin 3:7666de697752 65 LogSelectScreen *logSelect2;
OHstin 3:7666de697752 66 LogSelectScreen *logSelect1;
OHstin 3:7666de697752 67 LogDurationScreen *logDuration;
OHstin 3:7666de697752 68 LogDurationScreen *logDuration2;
OHstin 3:7666de697752 69 ViewLogScreen *viewLog;
OHstin 3:7666de697752 70 DeleteLogScreen *deleteLog;
OHstin 3:7666de697752 71 LogManager *log1;
OHstin 3:7666de697752 72 //LogManager *log2;
OHstin 0:5139f11cfc62 73
OHstin 0:5139f11cfc62 74 int main()
OHstin 0:5139f11cfc62 75 {
OHstin 3:7666de697752 76 // launch the sensors
OHstin 3:7666de697752 77 Thread thread(osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25), NULL);
OHstin 3:7666de697752 78 thread.start(sensorThread);
OHstin 3:7666de697752 79
OHstin 3:7666de697752 80 // launch the user interface
OHstin 3:7666de697752 81 Thread thread2(osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25), NULL);
OHstin 3:7666de697752 82 thread2.start(uiThread);
OHstin 3:7666de697752 83
OHstin 3:7666de697752 84 // launch serial communication with raspberry pi
OHstin 3:7666de697752 85 Thread thread3(osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25), NULL);
OHstin 3:7666de697752 86 thread3.start(raspiSerial);
OHstin 3:7666de697752 87
OHstin 3:7666de697752 88
OHstin 3:7666de697752 89 while(true) {
OHstin 3:7666de697752 90
OHstin 3:7666de697752 91
OHstin 3:7666de697752 92 }
OHstin 3:7666de697752 93
OHstin 3:7666de697752 94
OHstin 3:7666de697752 95 }
OHstin 3:7666de697752 96
OHstin 3:7666de697752 97 void sensorThread()
OHstin 3:7666de697752 98 {
OHstin 3:7666de697752 99 SensorSuite suite;
OHstin 3:7666de697752 100 // launch the sensor suite
OHstin 3:7666de697752 101 suite.begin();
OHstin 3:7666de697752 102 }
OHstin 3:7666de697752 103
OHstin 3:7666de697752 104 void uiThread()
OHstin 3:7666de697752 105 {
OHstin 3:7666de697752 106 // set the current time
OHstin 3:7666de697752 107 set_time(1475252667);
OHstin 0:5139f11cfc62 108 // Use this initializer if you're using a 1.8" TFT
OHstin 0:5139f11cfc62 109 tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab
OHstin 0:5139f11cfc62 110
OHstin 3:7666de697752 111
OHstin 3:7666de697752 112
OHstin 3:7666de697752 113 // create the settings object
OHstin 3:7666de697752 114 Settings settings;
OHstin 3:7666de697752 115 currentColor = settings.getBackgroundColor();
OHstin 3:7666de697752 116 backgroundColor = currentColor;
OHstin 3:7666de697752 117
OHstin 1:1354a7ebd0c6 118 tft.fillScreen(backgroundColor);
OHstin 1:1354a7ebd0c6 119 // landscape view
OHstin 0:5139f11cfc62 120 tft.setRotation(1);
OHstin 3:7666de697752 121 createScreens();
OHstin 2:104bec169fb6 122
OHstin 3:7666de697752 123 //struct setting lcdBackground;
OHstin 3:7666de697752 124 //lcdBackground.value = 1;
OHstin 3:7666de697752 125 //lcdBackground.key = 1;
OHstin 3:7666de697752 126 //rewind(ptr_myfile);
OHstin 3:7666de697752 127 //fseek(ptr_myfile,sizeof(struct setting)*0,SEEK_SET);
OHstin 3:7666de697752 128 //fwrite(&emptySetting, sizeof(struct setting), 1, ptr_myfile);
OHstin 3:7666de697752 129 //fread(&lcdBackground, sizeof(struct setting), 1, ptr_myfile);
OHstin 3:7666de697752 130
OHstin 3:7666de697752 131
OHstin 0:5139f11cfc62 132
OHstin 3:7666de697752 133 /**
OHstin 3:7666de697752 134 wait(5);
OHstin 3:7666de697752 135 relayOne = OFF;
OHstin 3:7666de697752 136 relayTwo = OFF;
OHstin 3:7666de697752 137 relayThree = OFF;
OHstin 3:7666de697752 138 wait(5);
OHstin 3:7666de697752 139 while(1) {
OHstin 3:7666de697752 140
OHstin 3:7666de697752 141 relayTwo = ON;
OHstin 3:7666de697752 142 relayOne = ON;
OHstin 3:7666de697752 143 relayThree = ON;
OHstin 3:7666de697752 144
OHstin 3:7666de697752 145 wait(5);
OHstin 3:7666de697752 146 relayOne = OFF;
OHstin 3:7666de697752 147 relayTwo = OFF;
OHstin 3:7666de697752 148 relayThree = OFF;
OHstin 3:7666de697752 149 wait(5);
OHstin 1:1354a7ebd0c6 150 }
OHstin 2:104bec169fb6 151
OHstin 3:7666de697752 152 **/
OHstin 3:7666de697752 153
OHstin 3:7666de697752 154
OHstin 3:7666de697752 155
OHstin 3:7666de697752 156
OHstin 3:7666de697752 157 bool backToFirstLayer = false;
OHstin 3:7666de697752 158 bool backToSecondLayer = false;
OHstin 3:7666de697752 159 bool backToThirdLayer = false;
OHstin 3:7666de697752 160 bool backToFourthLayer = false;
OHstin 3:7666de697752 161
OHstin 3:7666de697752 162 while(1) {
OHstin 3:7666de697752 163
OHstin 3:7666de697752 164 int val = menu->start();
OHstin 3:7666de697752 165
OHstin 3:7666de697752 166 if (val == 1) {
OHstin 3:7666de697752 167
OHstin 3:7666de697752 168 backToFirstLayer = false;
OHstin 3:7666de697752 169
OHstin 3:7666de697752 170 while(!backToFirstLayer) {
OHstin 3:7666de697752 171
OHstin 3:7666de697752 172 switch(batteriesScreen->start()) {
OHstin 3:7666de697752 173
OHstin 3:7666de697752 174 case 1:
OHstin 3:7666de697752 175 // clear screen
OHstin 3:7666de697752 176 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 177 backToSecondLayer = false;
OHstin 3:7666de697752 178
OHstin 3:7666de697752 179 while(!backToSecondLayer) {
OHstin 3:7666de697752 180 switch(battScreen->start(BATTERY_ONE)) {
OHstin 3:7666de697752 181 case -1:
OHstin 3:7666de697752 182 // clear screen
OHstin 3:7666de697752 183 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 184 backToSecondLayer = true;
OHstin 3:7666de697752 185 break;
OHstin 3:7666de697752 186 default:
OHstin 3:7666de697752 187 // do nothing
OHstin 3:7666de697752 188 break;
OHstin 3:7666de697752 189 }
OHstin 3:7666de697752 190 }
OHstin 3:7666de697752 191 break;
OHstin 3:7666de697752 192
OHstin 3:7666de697752 193 case 2:
OHstin 3:7666de697752 194 // clear screen
OHstin 3:7666de697752 195 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 196 backToSecondLayer = false;
OHstin 3:7666de697752 197
OHstin 3:7666de697752 198 while(!backToSecondLayer) {
OHstin 3:7666de697752 199 switch(battScreen->start(BATTERY_TWO)) {
OHstin 3:7666de697752 200 case -1:
OHstin 3:7666de697752 201 // clear screen
OHstin 3:7666de697752 202 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 203 backToSecondLayer = true;
OHstin 3:7666de697752 204 break;
OHstin 3:7666de697752 205 default:
OHstin 3:7666de697752 206 // do nothing
OHstin 3:7666de697752 207 break;
OHstin 3:7666de697752 208 }
OHstin 3:7666de697752 209 }
OHstin 3:7666de697752 210 break;
OHstin 3:7666de697752 211
OHstin 3:7666de697752 212 case -1:
OHstin 3:7666de697752 213 // clear screen
OHstin 3:7666de697752 214 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 215 backToFirstLayer = true;
OHstin 3:7666de697752 216 break;
OHstin 3:7666de697752 217
OHstin 3:7666de697752 218 default:
OHstin 3:7666de697752 219
OHstin 3:7666de697752 220 break;
OHstin 3:7666de697752 221 }
OHstin 3:7666de697752 222 }
OHstin 3:7666de697752 223
OHstin 3:7666de697752 224 } else if (val == 2) {
OHstin 3:7666de697752 225 outputScreen->start();
OHstin 3:7666de697752 226 } else if (val == 3) {
OHstin 3:7666de697752 227
OHstin 3:7666de697752 228 backToFirstLayer = false;
OHstin 3:7666de697752 229
OHstin 3:7666de697752 230 while(!backToFirstLayer) {
OHstin 3:7666de697752 231
OHstin 3:7666de697752 232 switch(solarScreen->start()) {
OHstin 3:7666de697752 233
OHstin 3:7666de697752 234 case 1:
OHstin 3:7666de697752 235 // clear screen
OHstin 3:7666de697752 236 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 237 backToSecondLayer = false;
OHstin 1:1354a7ebd0c6 238
OHstin 3:7666de697752 239 while(!backToSecondLayer) {
OHstin 3:7666de697752 240 switch(solarValueScreen->start()) {
OHstin 3:7666de697752 241 case -1:
OHstin 3:7666de697752 242 // clear screen
OHstin 3:7666de697752 243 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 244 backToSecondLayer = true;
OHstin 3:7666de697752 245 break;
OHstin 3:7666de697752 246 default:
OHstin 3:7666de697752 247 // do nothing
OHstin 3:7666de697752 248 break;
OHstin 3:7666de697752 249
OHstin 3:7666de697752 250 }
OHstin 3:7666de697752 251 }
OHstin 3:7666de697752 252 break;
OHstin 3:7666de697752 253
OHstin 3:7666de697752 254 case 2:
OHstin 3:7666de697752 255 // clear screen
OHstin 3:7666de697752 256 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 257 backToSecondLayer = false;
OHstin 3:7666de697752 258
OHstin 3:7666de697752 259 while(!backToSecondLayer) {
OHstin 3:7666de697752 260 switch(solarGraphScreen->start()) {
OHstin 3:7666de697752 261 case -1:
OHstin 3:7666de697752 262 // clear screen
OHstin 3:7666de697752 263 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 264 backToSecondLayer = true;
OHstin 3:7666de697752 265 break;
OHstin 3:7666de697752 266 default:
OHstin 3:7666de697752 267 // do nothing
OHstin 3:7666de697752 268 break;
OHstin 3:7666de697752 269
OHstin 3:7666de697752 270 }
OHstin 3:7666de697752 271 }
OHstin 3:7666de697752 272 break;
OHstin 3:7666de697752 273 case -1:
OHstin 3:7666de697752 274 // clear screen
OHstin 3:7666de697752 275 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 276 backToFirstLayer = true;
OHstin 3:7666de697752 277 break;
OHstin 2:104bec169fb6 278
OHstin 3:7666de697752 279 default:
OHstin 3:7666de697752 280 // do nothing
OHstin 3:7666de697752 281 break;
OHstin 3:7666de697752 282 }
OHstin 3:7666de697752 283 }
OHstin 3:7666de697752 284
OHstin 3:7666de697752 285 } else if (val == 4) {
OHstin 3:7666de697752 286
OHstin 3:7666de697752 287 backToFirstLayer = false;
OHstin 3:7666de697752 288
OHstin 3:7666de697752 289 while (!backToFirstLayer) {
OHstin 3:7666de697752 290
OHstin 3:7666de697752 291 switch(settingsScreen->start()) {
OHstin 3:7666de697752 292 case 1:
OHstin 3:7666de697752 293
OHstin 3:7666de697752 294 // clear screen
OHstin 3:7666de697752 295 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 296 backToSecondLayer = false;
OHstin 3:7666de697752 297
OHstin 3:7666de697752 298 while (!backToSecondLayer) {
OHstin 2:104bec169fb6 299
OHstin 3:7666de697752 300 switch(test->start()) {
OHstin 3:7666de697752 301 case -1:
OHstin 3:7666de697752 302 // clear screen
OHstin 3:7666de697752 303 // first check if the background color was changed
OHstin 3:7666de697752 304 // then change the background colors
OHstin 3:7666de697752 305 changeBackgroundColor();
OHstin 3:7666de697752 306 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 307 backToSecondLayer = true;
OHstin 3:7666de697752 308 break;
OHstin 3:7666de697752 309 }
OHstin 3:7666de697752 310 }
OHstin 3:7666de697752 311 break;
OHstin 3:7666de697752 312 case 2:
OHstin 3:7666de697752 313
OHstin 3:7666de697752 314 // clear the screen
OHstin 3:7666de697752 315 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 316 backToSecondLayer = false;
OHstin 3:7666de697752 317
OHstin 3:7666de697752 318 while (!backToSecondLayer) {
OHstin 3:7666de697752 319
OHstin 3:7666de697752 320 switch(logg->start()) {
OHstin 3:7666de697752 321
OHstin 3:7666de697752 322 case 1:
OHstin 3:7666de697752 323 // clear the screen
OHstin 3:7666de697752 324 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 325 backToThirdLayer = false;
OHstin 2:104bec169fb6 326
OHstin 3:7666de697752 327 while(!backToThirdLayer) {
OHstin 3:7666de697752 328
OHstin 3:7666de697752 329 switch(viewLog->start()) {
OHstin 3:7666de697752 330
OHstin 3:7666de697752 331 case -1:
OHstin 3:7666de697752 332 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 333 backToThirdLayer = true;
OHstin 3:7666de697752 334 break;
OHstin 3:7666de697752 335
OHstin 3:7666de697752 336 }
OHstin 3:7666de697752 337
OHstin 3:7666de697752 338 }
OHstin 3:7666de697752 339
OHstin 3:7666de697752 340 break;
OHstin 3:7666de697752 341
OHstin 3:7666de697752 342 case 2:
OHstin 3:7666de697752 343
OHstin 3:7666de697752 344 // clear the screen
OHstin 3:7666de697752 345 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 346 backToThirdLayer = false;
OHstin 3:7666de697752 347
OHstin 3:7666de697752 348 while(!backToThirdLayer) {
OHstin 3:7666de697752 349
OHstin 3:7666de697752 350 switch(logSelect2->start()) {
OHstin 3:7666de697752 351
OHstin 3:7666de697752 352 case 1:
OHstin 3:7666de697752 353 // clear the screen
OHstin 3:7666de697752 354 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 355 backToFourthLayer = false;
OHstin 3:7666de697752 356
OHstin 3:7666de697752 357 while(!backToFourthLayer) {
OHstin 3:7666de697752 358 switch(logDuration->start()) {
OHstin 3:7666de697752 359
OHstin 3:7666de697752 360 case 1:
OHstin 3:7666de697752 361 // start logging for 30 seconds
OHstin 3:7666de697752 362 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 363
OHstin 3:7666de697752 364
OHstin 3:7666de697752 365 // navigate all the way back to log screen
OHstin 3:7666de697752 366 backToFourthLayer = true;
OHstin 3:7666de697752 367 backToThirdLayer = true;
OHstin 3:7666de697752 368 break;
OHstin 3:7666de697752 369 case 2:
OHstin 3:7666de697752 370 // start logging for 1 minute
OHstin 3:7666de697752 371 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 372
OHstin 3:7666de697752 373
OHstin 3:7666de697752 374 // navigate all the way to log screen
OHstin 3:7666de697752 375 backToFourthLayer = true;
OHstin 3:7666de697752 376 backToThirdLayer = true;
OHstin 3:7666de697752 377 break;
OHstin 3:7666de697752 378
OHstin 3:7666de697752 379 case -1:
OHstin 3:7666de697752 380 // clear the screen
OHstin 3:7666de697752 381 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 382 backToFourthLayer = true;
OHstin 3:7666de697752 383 }
OHstin 3:7666de697752 384 }
OHstin 3:7666de697752 385 break;
OHstin 3:7666de697752 386 case 2:
OHstin 3:7666de697752 387 // clear the screen
OHstin 3:7666de697752 388 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 389 backToFourthLayer = false;
OHstin 3:7666de697752 390
OHstin 3:7666de697752 391 while(!backToFourthLayer) {
OHstin 3:7666de697752 392 switch(logDuration->start()) {
OHstin 3:7666de697752 393
OHstin 3:7666de697752 394 case 1:
OHstin 3:7666de697752 395 // start logging for 30 seconds
OHstin 3:7666de697752 396 log1 = new LogManager();
OHstin 3:7666de697752 397 log1->createNewLog(POWER_CONSUMPTION,THIRTY_SECONDS);
OHstin 3:7666de697752 398 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 399
OHstin 3:7666de697752 400 // navigate all the way back to log screen
OHstin 3:7666de697752 401 backToFourthLayer = true;
OHstin 3:7666de697752 402 backToThirdLayer = true;
OHstin 3:7666de697752 403 break;
OHstin 3:7666de697752 404 case 2:
OHstin 3:7666de697752 405 // start logging for 1 minute
OHstin 3:7666de697752 406 //log1 = new LogManager();
OHstin 3:7666de697752 407 //log1.createNewLog(ONE_MINUTE,SOLAR_POWER);
OHstin 3:7666de697752 408 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 409
OHstin 3:7666de697752 410 // navigate all the way to log screen
OHstin 3:7666de697752 411 backToFourthLayer = true;
OHstin 3:7666de697752 412 backToThirdLayer = true;
OHstin 3:7666de697752 413 break;
OHstin 3:7666de697752 414
OHstin 3:7666de697752 415 case -1:
OHstin 3:7666de697752 416 // clear the screen
OHstin 3:7666de697752 417 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 418 backToFourthLayer = true;
OHstin 3:7666de697752 419 }
OHstin 3:7666de697752 420 }
OHstin 3:7666de697752 421 break;
OHstin 3:7666de697752 422
OHstin 3:7666de697752 423 case -1:
OHstin 3:7666de697752 424 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 425 backToThirdLayer = true;
OHstin 3:7666de697752 426 break;
OHstin 3:7666de697752 427
OHstin 3:7666de697752 428 default:
OHstin 3:7666de697752 429 break;
OHstin 3:7666de697752 430 }
OHstin 3:7666de697752 431 }
OHstin 3:7666de697752 432 break;
OHstin 3:7666de697752 433 case 3:
OHstin 3:7666de697752 434 // clear the screen
OHstin 3:7666de697752 435 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 436 backToThirdLayer = false;
OHstin 3:7666de697752 437
OHstin 3:7666de697752 438 while(!backToThirdLayer) {
OHstin 3:7666de697752 439
OHstin 3:7666de697752 440 switch(deleteLog->start()) {
OHstin 3:7666de697752 441 case -1:
OHstin 3:7666de697752 442 // clear the screen
OHstin 3:7666de697752 443 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 444 backToThirdLayer = true;
OHstin 3:7666de697752 445 }
OHstin 3:7666de697752 446 }
OHstin 3:7666de697752 447 break;
OHstin 3:7666de697752 448 case -1:
OHstin 3:7666de697752 449
OHstin 3:7666de697752 450 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 451 backToSecondLayer = true;
OHstin 3:7666de697752 452 break;
OHstin 3:7666de697752 453 default:
OHstin 3:7666de697752 454 break;
OHstin 3:7666de697752 455 }
OHstin 3:7666de697752 456 }
OHstin 3:7666de697752 457 break;
OHstin 3:7666de697752 458 case -1:
OHstin 3:7666de697752 459 // clear screen
OHstin 3:7666de697752 460 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 461 backToFirstLayer = true;
OHstin 3:7666de697752 462 break;
OHstin 3:7666de697752 463 }
OHstin 3:7666de697752 464
OHstin 3:7666de697752 465 }
OHstin 3:7666de697752 466
OHstin 0:5139f11cfc62 467 }
OHstin 3:7666de697752 468 tft.fillScreen(backgroundColor);
OHstin 3:7666de697752 469 }
OHstin 3:7666de697752 470
OHstin 3:7666de697752 471
OHstin 3:7666de697752 472 }
OHstin 3:7666de697752 473
OHstin 3:7666de697752 474
OHstin 3:7666de697752 475 void changeBackgroundColor()
OHstin 3:7666de697752 476 {
OHstin 3:7666de697752 477 Settings settings;
OHstin 3:7666de697752 478 if (currentColor != settings.getBackgroundColor()) {
OHstin 3:7666de697752 479 currentColor = settings.getBackgroundColor();
OHstin 3:7666de697752 480 backgroundColor = currentColor;
OHstin 2:104bec169fb6 481
OHstin 3:7666de697752 482 // delete all the pointer
OHstin 3:7666de697752 483 delete menu;
OHstin 3:7666de697752 484 delete batteriesScreen;
OHstin 3:7666de697752 485 delete solarScreen;
OHstin 3:7666de697752 486 delete outputScreen;
OHstin 3:7666de697752 487 delete settingsScreen;
OHstin 3:7666de697752 488 delete solarGraphScreen;
OHstin 3:7666de697752 489 delete test;
OHstin 3:7666de697752 490 delete logg;
OHstin 3:7666de697752 491 delete logSelect2;
OHstin 3:7666de697752 492 delete logDuration;
OHstin 3:7666de697752 493 delete viewLog;
OHstin 3:7666de697752 494 delete deleteLog;
OHstin 3:7666de697752 495 delete battScreen;
OHstin 3:7666de697752 496 delete solarValueScreen;
OHstin 2:104bec169fb6 497
OHstin 3:7666de697752 498 // create new screens
OHstin 3:7666de697752 499 createScreens();
OHstin 2:104bec169fb6 500
OHstin 0:5139f11cfc62 501 }
OHstin 1:1354a7ebd0c6 502
OHstin 0:5139f11cfc62 503 }
OHstin 0:5139f11cfc62 504
OHstin 3:7666de697752 505 void createScreens()
OHstin 0:5139f11cfc62 506 {
OHstin 3:7666de697752 507 menu = new MainMenuScreen(backgroundColor);
OHstin 3:7666de697752 508 batteriesScreen = new BatteriesScreen(backgroundColor);
OHstin 3:7666de697752 509 solarScreen = new SolarScreen(backgroundColor);
OHstin 3:7666de697752 510 outputScreen = new OutputScreen(backgroundColor);
OHstin 3:7666de697752 511 settingsScreen = new SettingsScreen(backgroundColor);
OHstin 3:7666de697752 512 solarGraphScreen = new SolarGraphScreen(backgroundColor);
OHstin 3:7666de697752 513 test = new TestScreen(backgroundColor);
OHstin 3:7666de697752 514 logg = new LogScreen(backgroundColor);
OHstin 3:7666de697752 515 logSelect2 = new LogSelectScreen(backgroundColor);
OHstin 3:7666de697752 516 logDuration = new LogDurationScreen(backgroundColor);
OHstin 3:7666de697752 517 viewLog = new ViewLogScreen(backgroundColor);
OHstin 3:7666de697752 518 deleteLog = new DeleteLogScreen(backgroundColor);
OHstin 3:7666de697752 519 battScreen = new BatteryScreen(backgroundColor);
OHstin 3:7666de697752 520 solarValueScreen = new SolarValueScreen(backgroundColor);
OHstin 3:7666de697752 521 }
OHstin 3:7666de697752 522