* AM2321的取温度间隔得大于2s,否则,i2c会不工作了 * SimpleTimer有个bug,会导致两次快速的读温度,现在读温度函数里加了保护 * Blynk有个bug,会导致无法把数据传到服务器 * 现在可以正常工作了

Dependencies:   mbed

Revision:
1:e34100dd6532
Parent:
0:740c1eb2df13
--- a/sensor.h	Thu Jun 23 11:16:14 2016 +0000
+++ b/sensor.h	Fri Jun 24 02:06:43 2016 +0000
@@ -98,9 +98,14 @@
 void updateLight(void)
 {
     uint16_t lt = gLight.read_u16();
-    lt = lt & 0x03FF;
+    pc.printf("lt0 = 0x%x, ", lt);
+    lt = lt & 0x03FF;// 10bit
+    //lt = lt >> 2;
+    //lt = (lt & 0x0FFF)>>2;
+    //lt = (lt >> 2) & 0x03FF;
     sensor_light = map(lt, 0, 1023, 0, 255);
-    //pc.printf("sensor_light=%f\r\n", sensor_light);
+    //sensor_light = map(lt, 0, 65535, 0, 65535);
+    pc.printf("lt=0x%x, sensor_light=%f\r\n", lt, sensor_light);
     sensorPM25 += 1.0;
 }
 #endif
@@ -110,8 +115,9 @@
 {
     //Sensor_etoh = map(analogRead(A2), 0, 1023, 0, 30);
     uint16_t ch4 = gCH4.read_u16();
-    ch4 = ch4 & 0x03FF;
-    Sensor_etoh = map(ch4, 0, 1023, 0, 30);
+    //ch4 = ch4 & 0x03FF;
+    //Sensor_etoh = map(ch4, 0, 1023, 0, 30);
+    Sensor_etoh = map(ch4, 0, 65535, 0, 30);
     //pc.printf("CH4 = %d\r\n", ch4);
 }