diajzifsajoifajsoifaj

Dependencies:   BMP280 LGLCD

Fork of ELEC350-CWTEMPLATE-2017 by University of Plymouth - Stages 1, 2 and 3

Revision:
7:dd303488e55d
Parent:
6:f0601ebd2423
--- a/main.cpp	Fri Jan 05 17:56:59 2018 +0000
+++ b/main.cpp	Sun Jan 07 21:29:12 2018 +0000
@@ -1,81 +1,54 @@
 #include "components.hpp"
-#include "SDBlockDevice.h"
-#include "FATFileSystem.h"
-//#include "Networkbits.hpp"
 #include "mbed.h"
+#include "network.hpp"
 #include "lglcd.h"
-#include "stdio.h"
+InterruptIn sw1(USER_BUTTON);
+Thread samplesThread(osPriorityNormal);
+Thread sdThread(osPriorityLow);
+Thread sdRemoveThread(osPriorityLow);
+//Thread rtThread;
+//Thread stxThread;
+Thread netThread(osPriorityRealtime);
+void inter1();
+void inter2();
+void inter3();
+void inter4();
 // This is a very short demo that demonstrates all the hardware used in the coursework.
 // You will need a network connection set up (covered elsewhere). The host PC should have the address 10.0.0.1
-
-//Threads
-Thread nwrkThread;
+Ticker samples;
+Ticker remov;
+InterruptIn sdex(USER_BUTTON);
+Ticker storage;
+Ticker netTick;
+void inter1(){
+ sdcheck();
+ samplesThread.signal_set(SIG_READY);          
+}
+void inter2(){
+ sdThread.signal_set(SIG_READY2);  
+}
+void inter3(){
+ printf("CHECK REMOVE BUTTON\n\r");
+ if(sdex == 1){
+ sdRemoveThread.signal_set(SIG_REMOVE);
+ }
+ }
+ void inter4(){
+ netThread.signal_set(SIG_NET);
+}
 int main(){
+sdrun();
 lglcd mylcd(D7,D6,D5,D4,D3,D2);
 mylcd.clear();
-while(true){        
-double temp = sensor.getTemperature();
-double pressure = sensor.getPressure();
-double lightin = adcIn;
-char TEM[6];
-char PRE[5];  
-sprintf(TEM,"%.2f", temp);
-sprintf(PRE,"%.2f", pressure);
-printf(TEM);
-printf(PRE);
-mylcd.setline(1,1);
-mylcd.write("P:");
-mylcd.write(PRE);
-mylcd.setline(1,10);
-mylcd.write("T:");
-mylcd.write(TEM);
-mylcd.setline(2,1);
-mylcd.write("L:");
-if(lightin > 0.8 && lightin < 0.9)
-{
-mylcd.setline(2,4);
-mylcd.write("            ");
-mylcd.setline(2,4);
- mylcd.write("|||||||||");    
-}
-else if(lightin > 0.51 && lightin < 0.9)
-{
- mylcd.setline(2,4);
-mylcd.write("            ");
-mylcd.setline(2,4);
- mylcd.write("|||||");
-}
-else if(lightin > 0.4 && lightin < 0.5)
-{
- mylcd.setline(2,4);
-mylcd.write("            ");
-mylcd.setline(2,4);
- mylcd.write("|||");
-}
-else if(lightin > 0.2 && lightin < 0.39)
-{
- mylcd.setline(2,4);
-mylcd.write("            ");
-mylcd.setline(2,4);
- mylcd.write("LOW");
-} 
-else if(lightin < 0.19)
-{
-mylcd.setline(2,4);
-mylcd.write("            ");
-mylcd.setline(2,4);
-mylcd.write("disconnected");
-}
-
-//mylcd.write(light);
-//printf(adcIn);
-wait(0.4);
-      
-    }
-    
-    //Flash to indicate goodness
-  
-}
+sdThread.start(sdwrite);
+storage.attach(&inter2,10); //runs send to sd  based on last number (5) in this case (every 5 seconds)
+samplesThread.start(runanalysis); 
+samples.attach(&inter1,1);   //runs analysis based on last number (1) in this case (every 1 second)
+sdRemoveThread.start(sdremove);
+remov.attach(&inter3,3);//checks sd remove key every second
+netThread.start(networksend);
+netTick.attach(&inter4,0.01);
 
 
-    
+ 
+}
\ No newline at end of file