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:
9:8c63e4f3edab
Parent:
8:bab92fb7ef97
Child:
10:848a2205aed1
--- a/main.cpp	Wed Jan 26 16:28:52 2011 +0000
+++ b/main.cpp	Tue Feb 22 14:40:11 2011 +0000
@@ -8,8 +8,8 @@
  * @brief mbed Weather Platform
  */
 
-#define VERSION "mbed Weather Platform 0.1.3 (C) 2011 Suga koubou Co.,Ltd."
-#define USE_I2CLEDDISP // I2C LED Display
+#define VERSION "mbed Weather Platform 0.1.4 (C) 2011 Suga koubou Co.,Ltd."
+//#define USE_I2CLEDDISP // I2C LED Display
 //#define NONBLOCKING // ethernet function non-bloking
  
 #include "mbed.h"
@@ -28,7 +28,7 @@
 #include "I2CLEDDisp.h"
 #endif
 
-Serial pc(USBTX, USBRX);
+Serial pc(USBTX, USBRX), xbee(p13, p14);
 int seq = 0;
 char filename[20];
 Config conf;
@@ -117,16 +117,17 @@
 #endif
 
     locUpTime = locUpTime + 40; // 0.4s
+    led_y = 1;
 }
 
 void action (char *buf) {
     if (check_action('h')) {
         swout1 = 1;
-        led4 = 1;
+        led3 = 1;
     }
     if (check_action('l')) {
         swout1 = 0;
-        led4 = 0;
+        led3 = 0;
     }
     if (check_action('H')) {
         swout2 = 1;
@@ -151,6 +152,9 @@
             weatherstations();
         }
     }
+    if (check_action('X')) {
+        xbee.printf(buf);
+    }
 }
 
 void init () {
@@ -166,7 +170,7 @@
         eth_link.mode(PullUp);
         eth_speed.mode(PullUp);
         led_g = eth_link ? 1 : 0;
-        led_y = eth_speed ? 1 : 0;
+        led_y = 0;
         if (conf.ipaddr[0] == 255) {
             // dhcp
             eth = new EthernetNetIf;
@@ -295,6 +299,7 @@
         strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", localtime(&sec));
 
         // sensors
+        __disable_irq();
         bmp085.update();
         pres = bmp085.get_pressure();
         temp2 = bmp085.get_temperature();
@@ -312,11 +317,12 @@
         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);
-        pc.printf(buf);
         if (conf.filetype) {
             // csv
             writefile(buf);
         }
+        __enable_irq();
+        pc.printf(buf);
 
         action(&buf[20]);
 
@@ -334,7 +340,6 @@
 //            wait(1);
 //            pc.putc('.');
             led_g = eth_link ? 1 : 0;
-            led_y = eth_speed ? 1 : 0;
             Net::poll();
         }
         timer.reset();