kjdas

Dependencies:   BME280 BMP280 TextLCD mbed

Fork of CW_sd_0801 by Calvin Kalintra

Revision:
0:7023c3f98f36
Child:
1:dc21a6fce3af
diff -r 000000000000 -r 7023c3f98f36 data.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data.h	Sat Jan 06 17:28:05 2018 +0000
@@ -0,0 +1,166 @@
+#include "mbed.h"
+#include "BMP280.h"
+#include "date.h"
+float tempf;
+float pressuref;
+float lvl;
+float data_temp [120], data_press[120], data_light[120];
+BMP280 bmp(D14,D15,0x76);
+
+AnalogIn LDR(A0);
+int counterw = 0, full = 0, day, month, year, leap;
+
+void time_rule()
+{
+    if (ss == 10)
+    { 
+        ss = 0;
+        s++;
+    }
+    
+    if (s == 6 && ss == 0)
+    {
+        ss = 1;
+        s = 0;
+        mmi++;
+    }
+    
+    if (mmi == 10)
+    {
+        mmi = 0;
+        mi++;
+    }
+    
+    if (mi == 6 && mmi == 0)
+    {
+        mi = 0;
+        mmi = 1;
+        hh++;    
+    }
+    
+    if (hh == 10)
+    {
+        hh = 0;
+        h++;
+    }
+    
+    if(h == 2 && hh == 4)
+    {
+        h = 0;
+        hh = 0;
+        dd++;
+    }
+}
+
+
+void date_rule()
+{
+   if (mm == 10)
+    {
+        mm = 0;
+        m++;
+    }
+    
+    if (m == 1 && mm == 3)
+    {
+        m = 0;
+        mm = 1;
+        yyyy++;
+    }
+    
+    if (yyyy== 10)
+    {
+        yyyy = 0;
+        yyy++;
+    } 
+    if (yyy == 10)
+    {
+        yyy = 0;
+        yy++;
+    } 
+    if (yy == 10)
+    {
+        yy = 0;
+        y++;
+    } 
+    
+}
+
+
+void day_check()
+{
+    day = 10*d + dd;
+    month = mi*10+mmi;
+    year = y*1000+yy*100+yyy*10+yyyy;
+    if(month == 1||3||5||7||8||10||12)
+    {
+        if (day == 32)
+        {
+            mm++;
+            d = 0;
+            dd = 1;
+        } 
+    }
+
+    else if(month == 4||6||9||11 )
+    {
+        if (day == 31)
+        {
+            mm++;
+            d = 0;
+            dd = 1;
+        }
+    }
+    
+    else if(month == 2)
+    {
+        leap = year % 4;
+        if(leap == 0)
+        {
+            if (day == 30)
+            {
+                mm++;
+                d = 0;
+                dd = 1;
+            }
+        }
+        else 
+        {
+            if (day == 29)
+            {
+                mm++;
+                d = 0;
+                dd = 1;
+            }
+        }
+    }
+    date_rule();
+}
+
+
+
+
+void getdata()
+{
+    tempf = bmp.getTemperature();
+    //tempf = tempf*-1;
+    pressuref = bmp.getPressure();
+    lvl = LDR;
+}
+
+void store() 
+{  
+     data_temp[counterw] = tempf;
+     data_press[counterw] = pressuref;
+     data_light[counterw] = lvl;
+     
+     if (counterw == 120)
+     {
+         counterw = 0;
+         full = 1;
+     }
+     counterw++;
+}
+
+
+