mbed Weather Platform firmware http://mbed.org/users/okini3939/notebook/mbed-weather-platform-firmware/

Dependencies:   EthernetNetIf SDHCFileSystem I2CLEDDisp Agentbed NTPClient_NetServices mbed BMP085 HTTPClient ConfigFile I2CLCD

Revision:
14:ee6cc1632166
Parent:
13:20c0f845df68
Child:
15:07bfa25ba6ae
--- a/main.cpp	Sat Mar 19 21:24:01 2011 +0000
+++ b/main.cpp	Tue Mar 29 18:15:27 2011 +0000
@@ -8,7 +8,7 @@
  * @brief mbed Weather Platform
  */
 
-#define VERSION "mbed Weather Platform 0.2.0 (C) 2011 Suga koubou Co.,Ltd."
+#define VERSION "mbed Weather Platform 0.2.1 (C) 2011 Suga koubou Co.,Ltd."
 
 //#define NONBLOCKING // ethernet function non-bloking
  
@@ -29,13 +29,14 @@
 Serial pc(USBTX, USBRX), xbee(p13, p14);
 int seq = 0;
 char filename[20];
-Config conf;
+struct Config conf;
 DigitalOut led1(LED1), led2(LED2), led3(LED3), led4(LED4);
+LocalFileSystem local("local");
 SDFileSystem sd(p5, p6, p7, p8, "sd"); 
 MSCFileSystem *usb;
 
 // Sensors
-float pres, temp, humi, light, anemo, vane, rain, uv, moist, temp2;
+struct Sensor sensor, offset, sensor_old;
 I2C i2c(p9, p10);
 BMP085 bmp085(i2c, BMP085_oss4);
 SHT sht15(p12, p11, SHT_high); // sclock, data
@@ -180,14 +181,18 @@
     if (check_action('X')) {
         xbee.printf(buf);
     }
+    sensor_old = sensor;
 }
 
 void init () {
     FILE *fp;
 
-    config(CONFIG_FILE);
+    if (config("/sd/" CONFIG_FILE) == -1) {
+        pc.printf("local strage\r\n", conf.interval);
+        config("/local/" CONFIG_FILE);
+    }
 
-    pc.printf("Interval: %d sec\r\n", conf.interval);
+    pc.printf("\r\nInterval: %d sec\r\n", conf.interval);
 
     if (conf.ipaddr[0]) {
         // use ethernet
@@ -336,26 +341,27 @@
         // sensors
         __disable_irq();
         bmp085.update();
-        pres = bmp085.get_pressure();
-        temp2 = bmp085.get_temperature();
+        sensor.pres = bmp085.get_pressure() + offset.pres;
+        sensor.temp2 = bmp085.get_temperature();
 
         sht15.update(SHT_high);
-        temp = sht15.get_temperature();
-        humi = sht15.get_humidity();
+        sensor.temp = sht15.get_temperature() + offset.temp;
+        sensor.humi = sht15.get_humidity() + offset.humi;
 
-        anemo = wmeters.get_windspeed();
-        vane = wmeters.get_windvane();
-        rain = wmeters.get_raingauge();
+        sensor.anemo = wmeters.get_windspeed();
+        sensor.vane = wmeters.get_windvane();
+        sensor.rain = wmeters.get_raingauge();
 
-        light = get_photo(ailight);
+        sensor.light = get_photo(ailight);
         if (conf.inputtype == INPUT_MOIST) {
-            moist = get_moist(*aimoist);
+            sensor.moist = get_moist(*aimoist);
         } else {
-            moist = get_counter(0);
+            sensor.moist = get_counter(0);
         }
-        uv = get_uv(aiuv);
+        sensor.uv = get_uv(aiuv);
 
-        sprintf(&buf[strlen(buf)], ",%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f\r\n", pres, temp, humi, anemo, vane, rain, light, uv, moist, temp2);
+        sprintf(&buf[strlen(buf)], ",%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f\r\n",
+          sensor.pres, sensor.temp, sensor.humi, sensor.anemo, sensor.vane, sensor.rain, sensor.light, sensor.uv, sensor.moist, sensor.temp2);
         if (conf.filetype) {
             // csv
             writefile(buf);