Augustine Kizito / Mbed 2 deprecated Solar_Powered_Smart_Camera

Dependencies:   Adafruit_GFX Adafruit_ST7735 INA219 MODSERIAL MbedJSONValue mbed-rtos mbed

Revision:
4:c7b0670f96b2
Parent:
3:7666de697752
Child:
5:366f17f1ea9b
--- a/main.cpp	Sat Feb 04 20:17:44 2017 +0000
+++ b/main.cpp	Wed Mar 22 21:07:07 2017 +0000
@@ -3,6 +3,7 @@
 #include "MbedJSONValue.h"
 #include <string>
 #include "Adafruit_ST7735.h"
+#include "MailBoxes.h"
 #include "SensorSuite.h"
 
 
@@ -12,12 +13,11 @@
 DigitalOut relayTwo(p25);
 DigitalOut relayThree(p24);
 
+
 #define OFF 1
 #define ON 0
 
 
-
-
 uint16_t backgroundColor = ST7735_BLACK;
 
 
@@ -69,26 +69,27 @@
 ViewLogScreen *viewLog;
 DeleteLogScreen *deleteLog;
 LogManager *log1;
+RaspberryPiScreen *rpiScreen;
 //LogManager *log2;
 
 int main()
 {
     // launch the sensors
-    Thread thread(osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25), NULL); 
+    Thread thread(osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25), NULL);
     thread.start(sensorThread);
-    
+
     // launch the user interface
-    Thread thread2(osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25), NULL); 
+    Thread thread2(osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25), NULL);
     thread2.start(uiThread);
-    
+
     // launch serial communication with raspberry pi
-    Thread thread3(osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25), NULL); 
-    thread3.start(raspiSerial);
-    
-    
+    //Thread thread3(osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25), NULL);
+    //thread3.start(raspiSerial);
+
+
     while(true) {
 
- 
+
     }
 
 
@@ -222,7 +223,36 @@
             }
 
         } else  if (val == 2) {
-            outputScreen->start();
+
+            backToFirstLayer = false;
+
+            while (!backToFirstLayer) {
+
+                switch(outputScreen->start()) {
+
+                    case 1:
+                        // clear screen
+                        tft.fillScreen(backgroundColor);
+                        backToSecondLayer = false;
+
+                        while(!backToSecondLayer) {
+                            switch(rpiScreen->start()) {
+                                case -1:
+                                    // clear screen
+                                    tft.fillScreen(backgroundColor);
+                                    backToSecondLayer = true;
+                                    break;
+                                default:
+                                    // do nothing
+                                    break;
+                            }
+                        }
+                    
+                    default:
+                        // do nothing
+                        break;
+                }
+            }
         } else if (val == 3) {
 
             backToFirstLayer = false;
@@ -494,6 +524,7 @@
         delete deleteLog;
         delete battScreen;
         delete solarValueScreen;
+        delete rpiScreen;
 
         // create new screens
         createScreens();
@@ -518,5 +549,6 @@
     deleteLog = new DeleteLogScreen(backgroundColor);
     battScreen = new BatteryScreen(backgroundColor);
     solarValueScreen = new SolarValueScreen(backgroundColor);
+    rpiScreen = new RaspberryPiScreen(backgroundColor);
 }