mbed Weather Platform firmware http://mbed.org/users/okini3939/notebook/mbed-weather-platform-firmware/
Dependencies: ChaNFSSD EthernetNetIf I2CLEDDisp Agentbed ChaNFSUSB ILinterpreter mbed BMP085 WeatherMeters ConfigFile ChaNFS I2CLCD
Diff: ilip.cpp
- Revision:
- 1:6c7141895545
- Parent:
- 0:bdb53686c194
- Child:
- 2:a3e5edf84f74
--- a/ilip.cpp Mon Jul 04 15:16:45 2011 +0000 +++ b/ilip.cpp Sun Jul 10 15:36:46 2011 +0000 @@ -1,6 +1,13 @@ +/* + * Weather Station - mbed Weather Platform + * Copyright (c) 2011 Hiroshi Suga + * Released under the MIT License: http://mbed.org/license/mit + */ + /** @file - * @brief mbed Weather Platform + * @brief Weather Station */ + #include "mbed.h" #include "weather.h" #ifdef USE_IL @@ -9,7 +16,11 @@ static ILinterpreter ilip; #endif static Serial xbee(p13, p14); -static volatile int measure_flg = 0; +static volatile int measure_flg = 0, exinout_flg = 0; +#ifdef USE_EXINOUT +static DigitalIn *exin1, *exin2; +static DigitalOut *exout1, *exout2; +#endif #ifdef USE_IL // input relay @@ -113,9 +124,10 @@ } break; - case 'X': // XBee + case 'B': // XBee if (mne == MNE_OUT && reg) { xbee.printf(csv); + xbee.printf("\r\n"); } break; @@ -142,9 +154,13 @@ measure_flg = enable; +#ifdef USE_EXINOUT // set input -// sensor.input[0] = conf.inputtype ? *aimoist > 0.5 : 0; -// sensor.input[1] = swin2; + if (exinout_flg) { + sensor.input[0] = *exin1 ? 0 : 1; + sensor.input[1] = *exin2 ? 0 : 1; + } +#endif sensor_tmp = sensor; @@ -161,26 +177,46 @@ } #endif +#ifdef USE_EXINOUT // set output -// led3 = swout1 = sensor.output[0]; -// led4 = swout2 = sensor.output[1]; + if (exinout_flg) { + *exout1 = sensor.output[0]; + *exout2 = sensor.output[1]; + } +#endif sensor_old = sensor_tmp; } // init IL int init_ilip (char *dir) { + int r; char buf[40]; if (cfg.getValue("XBEE", buf, sizeof(buf))) { xbee.baud(atoi(chop(buf))); } +#ifdef USE_EXINOUT + if (cfg.getValue("INPUT", buf, sizeof(buf))) { + if (atoi(buf) == INPUT_EXINOUT) { + exout1 = new DigitalOut(p30); + exout2 = new DigitalOut(p29); + exin1 = new DigitalIn(p18); + exin1->mode(PullUp); + exin2 = new DigitalIn(p19); + exin2->mode(PullUp); + exinout_flg = 1; + } + } +#endif + #ifdef USE_IL strcpy(buf, dir); strcat(buf, IL_FILE); - if (! ilip.load(buf)) { - pc.printf("IL load %s\r\n", buf); + r = ilip.load(buf); + if (r > 0) { + pc.printf("IL load: %d\r\n", r); ilip.attach(cb_input, cb_output); } #endif