![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
newest
Dependencies: BME280 BMP280 TextLCD mbed
Fork of CW_watchdog_08012018 by
Diff: data.h
- Revision:
- 1:dc21a6fce3af
- Parent:
- 0:7023c3f98f36
- Child:
- 2:c696dfd53eeb
--- a/data.h Sat Jan 06 17:28:05 2018 +0000 +++ b/data.h Mon Jan 08 18:46:57 2018 +0000 @@ -4,8 +4,9 @@ float tempf; float pressuref; float lvl; -float data_temp [120], data_press[120], data_light[120]; -BMP280 bmp(D14,D15,0x76); +float data_temp [119], data_press[119], data_light[119]; +int date_a[199], time_a[199], time0_a[199], date0_a[199]; +BME280 bmp(D14,D15,0x76); AnalogIn LDR(A0); int counterw = 0, full = 0, day, month, year, leap; @@ -86,53 +87,166 @@ } +//void day_check() +//{ +// month = m*10+mm; +// +// switch (month){ +// case 1: +// d = d; +// if (d == 3 %% dd == 2) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// } +// break; +// +// case 2: +// if (d == 3 %% dd == 0) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// break; +// case 3: if (d == 3 %% dd == 2) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// break; +// case 4: if (d == 3 %% dd == 1) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// break; +// case 5: if (d == 3 %% dd == 2) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// break; +// case 6 :if (d == 3 %% dd == 1) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// break; +// +// case 7: if (d == 3 %% dd == 2) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// break; +// case 8: if (d == 3 %% dd == 2) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// break; +// case 9: if (d == 3 %% dd == 1) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// break; +// case 10: if (d == 3 %% dd == 2) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// break; +// case 11: if (d == 3 %% dd == 1) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// break; +// case 12: if (d == 3 %% dd == 2) +// { +// mm++; +// d = 0; +// dd = 1; +// } +// break; +// } +// date_rule(); +//} void day_check() { - day = 10*d + dd; - month = mi*10+mmi; + //day = 10*d + dd; + //month = m*10+mm; year = y*1000+yy*100+yyy*10+yyyy; - if(month == 1||3||5||7||8||10||12) + if((m == 0 && (mm == 1 || mm == 3 || mm == 5 || mm == 7 || mm == 8)) || (m ==1 && (mm == 0 || mm == 2))) { - if (day == 32) + if (d == 3 && dd == 0) { - mm++; - d = 0; + d = 3; dd = 1; - } - } - - else if(month == 4||6||9||11 ) - { - if (day == 31) + } + else if (d == 3 && dd == 2) { mm++; d = 0; dd = 1; } + + + } + + else if((m == 0 && (mm == 4 || mm == 6 || mm == 9)) || (m ==1 && mm == 1)) + { + if (d == 3 && dd == 0) + { + d = 3; + dd = 1; + } + else if (d == 3 && dd == 1) + { + mm++; + d = 0; + dd = 1; + } + + } - else if(month == 2) + else if(m == 0 && mm == 2) { - leap = year % 4; - if(leap == 0) - { - if (day == 30) + leap = year%4; + if (leap == 0) { - mm++; - d = 0; - dd = 1; + if (d == 3 && dd == 0) + { + mm++; + d = 0; + dd = 1; + } } - } - else - { - if (day == 29) + else if(leap != 0) { - mm++; - d = 0; - dd = 1; - } - } + if (d == 2 && dd == 9) + { + mm++; + d = 0; + dd = 1; + } + } + } date_rule(); } @@ -146,6 +260,7 @@ //tempf = tempf*-1; pressuref = bmp.getPressure(); lvl = LDR; + } void store() @@ -153,8 +268,11 @@ data_temp[counterw] = tempf; data_press[counterw] = pressuref; data_light[counterw] = lvl; - - if (counterw == 120) + date_a[counterw] = dd*1000000+m*100000+mm*10000+y*1000+yy*100+yyy*10+yyyy; + time_a[counterw] = ss*10000+mi*1000+mmi*100+h*10+hh; + date0_a[counterw] = d; + time0_a[counterw] = s; + if (counterw == 119) { counterw = 0; full = 1;