Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BME280 BMP280 TextLCD mbed
data.h
00001 #include "mbed.h" 00002 #include "BMP280.h" 00003 #include "date.h" 00004 float tempf; 00005 float pressuref; 00006 float lvl; 00007 float data_temp [120], data_press[120], data_light[120]; 00008 BMP280 bmp(D14,D15,0x76); 00009 00010 AnalogIn LDR(A0); 00011 int counterw = 0, full = 0, day, month, year, leap; 00012 00013 void time_rule() 00014 { 00015 if (ss == 10) 00016 { 00017 ss = 0; 00018 s++; 00019 } 00020 00021 if (s == 6 && ss == 0) 00022 { 00023 ss = 1; 00024 s = 0; 00025 mmi++; 00026 } 00027 00028 if (mmi == 10) 00029 { 00030 mmi = 0; 00031 mi++; 00032 } 00033 00034 if (mi == 6 && mmi == 0) 00035 { 00036 mi = 0; 00037 mmi = 1; 00038 hh++; 00039 } 00040 00041 if (hh == 10) 00042 { 00043 hh = 0; 00044 h++; 00045 } 00046 00047 if(h == 2 && hh == 4) 00048 { 00049 h = 0; 00050 hh = 0; 00051 dd++; 00052 } 00053 } 00054 00055 00056 void date_rule() 00057 { 00058 if (mm == 10) 00059 { 00060 mm = 0; 00061 m++; 00062 } 00063 00064 if (m == 1 && mm == 3) 00065 { 00066 m = 0; 00067 mm = 1; 00068 yyyy++; 00069 } 00070 00071 if (yyyy== 10) 00072 { 00073 yyyy = 0; 00074 yyy++; 00075 } 00076 if (yyy == 10) 00077 { 00078 yyy = 0; 00079 yy++; 00080 } 00081 if (yy == 10) 00082 { 00083 yy = 0; 00084 y++; 00085 } 00086 00087 } 00088 00089 00090 void day_check() 00091 { 00092 day = 10*d + dd; 00093 month = mi*10+mmi; 00094 year = y*1000+yy*100+yyy*10+yyyy; 00095 if(month == 1||3||5||7||8||10||12) 00096 { 00097 if (day == 32) 00098 { 00099 mm++; 00100 d = 0; 00101 dd = 1; 00102 } 00103 } 00104 00105 else if(month == 4||6||9||11 ) 00106 { 00107 if (day == 31) 00108 { 00109 mm++; 00110 d = 0; 00111 dd = 1; 00112 } 00113 } 00114 00115 else if(month == 2) 00116 { 00117 leap = year % 4; 00118 if(leap == 0) 00119 { 00120 if (day == 30) 00121 { 00122 mm++; 00123 d = 0; 00124 dd = 1; 00125 } 00126 } 00127 else 00128 { 00129 if (day == 29) 00130 { 00131 mm++; 00132 d = 0; 00133 dd = 1; 00134 } 00135 } 00136 } 00137 date_rule(); 00138 } 00139 00140 00141 00142 00143 void getdata() 00144 { 00145 tempf = bmp.getTemperature(); 00146 //tempf = tempf*-1; 00147 pressuref = bmp.getPressure(); 00148 lvl = LDR; 00149 } 00150 00151 void store() 00152 { 00153 data_temp[counterw] = tempf; 00154 data_press[counterw] = pressuref; 00155 data_light[counterw] = lvl; 00156 00157 if (counterw == 120) 00158 { 00159 counterw = 0; 00160 full = 1; 00161 } 00162 counterw++; 00163 } 00164 00165 00166
Generated on Tue Jul 19 2022 21:47:04 by
