Leeds University

Dependencies:   N5110 beep mbed

Files at this revision

API Documentation at this revision

Comitter:
Gaz142
Date:
Mon May 11 21:58:29 2015 +0000
Parent:
0:e8b157a824e7
Commit message:
New;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r e8b157a824e7 -r 477ed4a96308 main.cpp
--- a/main.cpp	Mon May 11 20:52:07 2015 +0000
+++ b/main.cpp	Mon May 11 21:58:29 2015 +0000
@@ -21,7 +21,8 @@
 
 Measurement measurement;             // Store the measurement values
 Ticker message;                      // Alert message
-Ticker valueReading;                 // Each 60 sec a reading is taken
+Ticker valueReading;  
+Ticker interrupt;               // Each 60 sec a reading is taken
 LocalFileSystem Local("local");      // Store the data
 
 void celsius(); // Celsius function
@@ -33,7 +34,7 @@
 void registerTime(); // Time
 void setBrightness(float brightness); // Init the brightness
 void fahrenheit(); // Fahrenheit function
-void dataWite(float Measurement);// register data
+void dataWrite(float Measurement);// register data
 void error(); // indicate error 
 void stop();  // stop the opreation
 void timeChange(); // intreeupt the time
@@ -43,6 +44,7 @@
 int unitChangerFlag = 0;
 int celsiusFlag =0;
 int brightnessButtonFlag =0;
+int setTimeFlag = 0;
 
 char buffer[30]; // creat a charracter
 char xString[16]; 
@@ -110,8 +112,37 @@
     delayOption(); // calls the delay function
     lcd.refresh(); // refresh the LCD.
 
+// Section for tempearture
+    valueReading.attach(&stop,10.0);  // Read temperature every 10 secondas
+
+    // section for keeping track of time
+    serial.attach(&ISR); // attach serial ISR
+    valueReading.attach(&stop,300.0);
+    set_time(1425386440); // initialise time to current time
+
+    interrupt.attach(&timeChange, 300.0); // print current time every 10.o seconds
+
+    // Section for writing files
+    //int counter = 0; // variable to increment
+
     while(1) {
 
+ stop();
+        // section for writing files
+       // float temperature = getTemperature();
+        dataWrite(measurement.temperatureC); // write current value to disk
+        
+        
+        
+        wait(1.0); // small delay
+        // Section for time tracking
+        if (setTimeFlag) { // if updated time has been sent
+            setTimeFlag = 0; // clear flag
+            registerTime(); // update time
+        }
+
+
+
         if(brightnessButtonFlag == 6) { // starts / and after the last click it return to here and wakes up the screen
             displayOn();
             lcd.setBrightness(0.2);