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 16:df39da7bef98, committed 2011-04-01
- Comitter:
- okini3939
- Date:
- Fri Apr 01 23:37:04 2011 +0000
- Parent:
- 15:07bfa25ba6ae
- Child:
- 17:7c9d111a5d45
- Commit message:
Changed in this revision
--- a/conf.cpp Wed Mar 30 20:09:04 2011 +0000 +++ b/conf.cpp Fri Apr 01 23:37:04 2011 +0000 @@ -4,17 +4,10 @@ #include "mbed.h" #include "conf.h" #include "ConfigFile.h" -#include "I2CLEDDisp.h" -#include "I2CLCD.h" extern Serial xbee; extern Config conf; extern Sensor sensor, offset, sensor_old; -extern I2C i2c; -extern I2CLCD *lcd; -extern I2CLEDDisp *leddisp; -extern AnalogIn *aimoist; -extern InterruptIn *intcounter; void int_counter(); @@ -267,8 +260,6 @@ ConfigFile cfg; char buf[80], key[20]; int ip0, ip1, ip2, ip3; - enum I2CLCDType lcdtype = LCD16x2; - enum I2CLCDConfig lcdconf = LCDCFG_3V; conf.ipaddr = IpAddr(0, 0, 0, 0); conf.netmask = IpAddr(255, 255, 255, 0); @@ -290,6 +281,8 @@ conf.snmp_commname[0] = 0; conf.leddisp_mesg[0] = 0; conf.lcd_mesg[0] = 0; + conf.lcdtype = LCD16x2; + conf.lcdconf = LCDCFG_3V; memset(&offset, 0, sizeof(offset)); memset(&sensor_old, 0, sizeof(sensor_old)); @@ -358,18 +351,16 @@ chop(conf.snmp_commname); if (cfg.getValue("LCD_TYPE", buf, sizeof(buf))) { - lcdtype = (enum I2CLCDType)atoi(chop(buf)); + conf.lcdtype = (enum I2CLCDType)atoi(chop(buf)); } if (cfg.getValue("LCD_CONF", buf, sizeof(buf))) { - lcdconf = (enum I2CLCDConfig)atoi(chop(buf)); + conf.lcdconf = (enum I2CLCDConfig)atoi(chop(buf)); } if (cfg.getValue("LCD_MESG", conf.lcd_mesg, sizeof(conf.lcd_mesg))) { chop(conf.lcd_mesg); - lcd = new I2CLCD(i2c, I2CLCD_ADDR, lcdtype, lcdconf); } if (cfg.getValue("LEDDISP_MESG", conf.leddisp_mesg, sizeof(conf.leddisp_mesg))) { chop(conf.leddisp_mesg); - leddisp = new I2CLEDDisp(i2c); } if (cfg.getValue("XBEE", buf, sizeof(buf))) { @@ -379,19 +370,6 @@ if (cfg.getValue("INPUT", buf, sizeof(buf))) { conf.inputtype = (enum eINPUTTYPE)atoi(chop(buf)); } - if (cfg.getValue("INPUT", buf, sizeof(buf))) { - conf.inputtype = (enum eINPUTTYPE)atoi(chop(buf)); - } - if (conf.inputtype == INPUT_FALL) { - intcounter = new InterruptIn(p18); - intcounter->fall(&int_counter); - } else - if (conf.inputtype == INPUT_RISE) { - intcounter = new InterruptIn(p18); - intcounter->rise(&int_counter); - } else { - aimoist = new AnalogIn(p18); - } for (i = 0; i < CF_ACTION_NUM; i ++) { sprintf(key, "ACTION[%d]", i);
--- a/conf.h Wed Mar 30 20:09:04 2011 +0000 +++ b/conf.h Fri Apr 01 23:37:04 2011 +0000 @@ -3,6 +3,8 @@ */ #include "mbed.h" #include "EthernetNetIf.h" +#include "I2CLEDDisp.h" +#include "I2CLCD.h" #define CONFIG_FILE "weather.cfg" @@ -60,6 +62,8 @@ char stations_id[8], stations_pin[34]; char snmp_commname[30]; char lcd_mesg[CF_MAXLEN_VALUE]; + enum I2CLCDType lcdtype; + enum I2CLCDConfig lcdconf; char leddisp_mesg[CF_MAXLEN_VALUE]; enum eINPUTTYPE inputtype; };
--- a/main.cpp Wed Mar 30 20:09:04 2011 +0000 +++ b/main.cpp Fri Apr 01 23:37:04 2011 +0000 @@ -197,6 +197,16 @@ pc.printf("\r\nInterval: %d sec\r\n", conf.interval); + if (conf.lcd_mesg[0]) { + // use I2C LCD + lcd = new I2CLCD(i2c, I2CLCD_ADDR, conf.lcdtype, conf.lcdconf); + } + + if (conf.leddisp_mesg[0]) { + // use I2C LED Display + leddisp = new I2CLEDDisp(i2c); + } + if (conf.ipaddr[0]) { // use ethernet @@ -241,6 +251,10 @@ pc.printf("Snmp community name: %s\r\n", conf.snmp_commname); } } + } else { + // not use ethernet + led_g = eth_link ? 0 : 1; + led_g2 = 0; } if (conf.filetype) { @@ -281,11 +295,17 @@ pc.printf("Actions: %d\r\n", conf.actionscount); - if (! conf.ipaddr[0]) { - led_g = eth_link ? 0 : 1; - led_g2 = 0; + if (conf.inputtype == INPUT_FALL) { + intcounter = new InterruptIn(p18); + intcounter->fall(&int_counter); + } else + if (conf.inputtype == INPUT_RISE) { + intcounter = new InterruptIn(p18); + intcounter->rise(&int_counter); + } else { + aimoist = new AnalogIn(p18); } - + count_counter = 0; lastCountTime = 0; }