Augustine Kizito / Mbed 2 deprecated Solar_Powered_Smart_Camera

Dependencies:   Adafruit_GFX Adafruit_ST7735 INA219 MODSERIAL MbedJSONValue mbed-rtos mbed

Committer:
OHstin
Date:
Wed Mar 22 21:07:07 2017 +0000
Revision:
4:c7b0670f96b2
Parent:
3:7666de697752
Child:
5:366f17f1ea9b
Version Before Perf Board Transfer

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