Augustine Kizito / Mbed 2 deprecated Solar_Powered_Smart_Camera

Dependencies:   Adafruit_GFX Adafruit_ST7735 INA219 MODSERIAL MbedJSONValue mbed-rtos mbed

Committer:
OHstin
Date:
Thu Mar 23 10:59:50 2017 +0000
Revision:
5:366f17f1ea9b
Parent:
4:c7b0670f96b2
Child:
6:196a63a3378d
PerfBoard

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