Keiarash Zoughi's Multi-Sensor for weather detection.

Dependencies:   BMP180 N5110 mbed

Revision:
7:c39d54bdff28
Parent:
6:07133c44d3eb
Child:
8:956a130ebdf5
--- a/main.cpp	Fri May 08 10:26:12 2015 +0000
+++ b/main.cpp	Fri May 08 10:58:08 2015 +0000
@@ -47,28 +47,38 @@
     // or create formatted strings - ensure they aren't more than 14 characters long
     float temperature = measurement.temperature;
     // display on screen
-//
+char buffer[14];  // each charact
+int length = sprintf(buffer,"T = %.2f C",temperature); // print formatted data to buffer
+        // it is important the format specifier ensures the length will fit in the buffer
+        if (length <= 14)  // if string will fit on display
+        lcd.printString(buffer,0,5);           // display on screen
+
+
     float pressure = measurement.pressure;  // same idea with floats
 
     if(temperature > 30.0 ) {
 
-        lcd.printString("temperature high!",1,1);
+        lcd.printString("TEMP HIGH!",1,1);
+        Redled=1.0;
 
-        Redled=1.0;
 
 
     } else if(temperature < 3.0) {
 
-        lcd.printString("temperature low!",1,1);
-
+        lcd.printString("TEMP LOW!",1,1);
         Redled= 1.0;
 
 
     } else {
-        lcd.printString("temperature ok!",1,1);
-
+        lcd.printString("TEMP OK!",1,1);
+        Redled = 0.0;
     }
+
+
     wait(3);
+lcd.clear();
+
+
 }
 
 
@@ -78,6 +88,7 @@
 
 
 
+
 //shows pressure reading and temperature
 void measurement()
 {
@@ -192,6 +203,9 @@
     Measurement measurement;  // measurement structure declared in BMP180 class
     int i = 0;
     float graph[84]= {0};
+    
+    
+    
     while(1) {
 
         // read values (T in Celsius and P in mb) and print over serial port
@@ -223,6 +237,77 @@
 }
 
 
+void graphScreen(){
+    
+ lcd.clear();
+    lcd.printString("Hold button!",6,2);//select measure menu
+    wait(1);
+    lcd.clear();
+    selectedOption = 0;
+
+    while(1) {
+
+        lcd.drawRect(70,6,10,10,1);
+        lcd.drawRect(70,21,10,10,0);
+        lcd.drawRect(70,37,10,10,0);//check box 3
+        lcd.printString("line graph",1,1);
+        lcd.printString("pie chart",1,3);
+        lcd.printString("go back",1,5);
+
+        lcd.printString(">",62,1);
+        selectedOption = 1;
+        if (pushbutton1)
+            break;
+        wait(2);
+        lcd.clear();
+
+        lcd.drawRect(70,6,10,10,0);
+        lcd.drawRect(70,21,10,10,1);
+        lcd.drawRect(70,37,10,10,0);//check box 3
+        lcd.printString("line graph",1,1);
+        lcd.printString("pie chart",1,5);
+
+        lcd.printString("go back",1,3);
+        lcd.printString(">",62,3);
+        selectedOption = 2;
+        if (pushbutton1)
+            break;
+        wait(2);
+        lcd.clear();
+
+        lcd.drawRect(70,6,10,10,0);
+        lcd.drawRect(70,21,10,10,0);
+        lcd.drawRect(70,37,10,10,1);//check box 3
+        lcd.printString("line graph",1,1);
+        lcd.printString("pie chart",1,3);
+        lcd.printString("go back",1,5);
+        lcd.printString(">",62,5);
+        selectedOption = 3;
+        if (pushbutton1)
+            break;
+        wait(2);
+        lcd.clear();
+
+    }
+
+    if(selectedOption == 1) {
+
+        lcd.clear();
+    }
+
+    if(selectedOption == 2) {
+
+        graph();
+
+    }
+
+    if(selectedOption == 3) {
+
+        graph();
+    }
+
+
+}   
 
 
 
@@ -351,6 +436,9 @@
     if(selectedOption == 2) {
 
         check();
+        leds = 15;
+        wait(0.5);
+        leds = 0;
 
     }
 }
@@ -359,7 +447,7 @@
 
 void mainScreen()
 {
-lcd.clear();
+    lcd.clear();
     lcd.printString("Hold Button!",6,2);//select measure menu
 
     wait(1);
@@ -435,7 +523,7 @@
 
     if(selectedOption == 3) {
 
-        graph();
+        graphScreen();
     }
 }
 
@@ -458,7 +546,7 @@
 
     lcd.init();
     introScreen();
-     wait(3);
+    wait(3);
     Redled =0;
     lcd.clear();
     mainScreen();
@@ -466,7 +554,7 @@
     while(1) {
         lcd.printString("main menu...",1,2);
         wait(1);
-        
+
         mainScreen();