Augustine Kizito / Mbed 2 deprecated Solar_Powered_Smart_Camera

Dependencies:   Adafruit_GFX Adafruit_ST7735 INA219 MODSERIAL MbedJSONValue mbed-rtos mbed

Committer:
OHstin
Date:
Sun Apr 30 17:19:22 2017 +0000
Revision:
6:196a63a3378d
Parent:
5:366f17f1ea9b
Final Code for mbed operation

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