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
Diff: main.cpp
- Revision:
- 13:20c0f845df68
- Parent:
- 12:d9264218a5e9
- Child:
- 14:ee6cc1632166
--- a/main.cpp Thu Mar 17 22:46:03 2011 +0000 +++ b/main.cpp Sat Mar 19 21:24:01 2011 +0000 @@ -43,7 +43,7 @@ AnalogIn ailight(p16), aiuv(p17); AnalogIn *aimoist; InterruptIn *intcounter; -int count_counter, counter; +int count_counter; unsigned long lastCountTime; DigitalOut swout1(p29), swout2(p30); @@ -57,7 +57,7 @@ EthernetNetIf *eth; NTPClient *ntp; HTTPClient *clientP, *clientT; -DigitalOut led_g(p25), led_y(p26); +DigitalOut led_g2(p24),led_g(p25), led_y(p26); DigitalIn eth_link(P1_25), eth_speed(P1_26); extern AgentbedClass Agentbed; @@ -108,9 +108,9 @@ t = (float)count_counter; } else { if (locUpTime > lastCountTime) { - t = (float)(locUpTime - lastCountTime) / 60000.0; + t = (float)(locUpTime - lastCountTime) / 6000.0; } else { - t = (float)(0xffffffff - lastCountTime + locUpTime) / 60000.0; + t = (float)(0xffffffff - lastCountTime + locUpTime) / 6000.0; } t = (float)count_counter / t; } @@ -195,6 +195,7 @@ eth_link.mode(PullUp); eth_speed.mode(PullUp); led_g = eth_link ? 1 : 0; + led_g2 = 1; led_y = 0; if (conf.ipaddr[0] == 255) { // dhcp @@ -269,6 +270,16 @@ led2 = 1; } } + + pc.printf("Actions: %d\r\n", conf.actionscount); + + if (! conf.ipaddr[0]) { + led_g = eth_link ? 0 : 1; + led_g2 = 0; + } + + count_counter = 0; + lastCountTime = 0; } int main () { @@ -310,6 +321,7 @@ timer.start(); #ifdef NONBLOCKING while (timer.read() < 5) { + wait_ms(1); Net::poll(); } timer.reset(); @@ -339,7 +351,7 @@ if (conf.inputtype == INPUT_MOIST) { moist = get_moist(*aimoist); } else { - moist = get_counter(1); + moist = get_counter(0); } uv = get_uv(aiuv); @@ -371,8 +383,25 @@ while (timer.read() < conf.interval) { // wait(1); // pc.putc('.'); - led_g = eth_link ? 1 : 0; + wait_ms(1); + if (conf.ipaddr[0]) { + led_g = eth_link ? 1 : 0; + led_g2 = 1; + } else { + led_g = eth_link ? 0 : 1; + led_g2 = 0; + } Net::poll(); + + if (pc.readable()) { + int i; + i = pc.getc(); + if (i == ' ') { + break; + } else { + pc.printf("( %d )\r\n", (int)timer.read()); + } + } } timer.reset(); }