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
main.cpp
- Committer:
- okini3939
- Date:
- 2011-07-04
- Revision:
- 0:bdb53686c194
- Child:
- 1:6c7141895545
File content as of revision 0:bdb53686c194:
#include "mbed.h" #include "weather.h" const char VERSION[] = "mbed Weather Platform 0.4.0 (C) 2011 Suga koubou"; Serial pc(USBTX, USBRX); DigitalOut led1(LED1), led2(LED2), led3(LED3), led4(LED4); static volatile int interval = 60; char csv[120]; static char csv_mesg[120] = "%y-%m-%d %h:%i:%s,%.2P,%.2T,%.2H,%.2A,%.2V,%.2R,%.2L,%.2U,%.2M,%.2p\r\n"; // Interrupt 10Hz void isr_timer () { // uptime locUpTime = locUpTime + 10; pool_ilip(); pool_display(); LED_NET_OFF; } void init () { char buf[128]; init_conf(); if (cfg.getValue("DIR", buf, sizeof(buf))) { init_ilip(buf); } if (cfg.getValue("BAUD", buf, sizeof(buf))) { pc.baud(atoi(buf)); } if (cfg.getValue("CSV_MESG", csv_mesg, sizeof(csv_mesg))) { chop(csv_mesg); } if (cfg.getValue("INTERVAL", buf, sizeof(buf))) { interval = atoi(buf); pc.printf("Interval: %d sec.\r\n", interval); } init_file(); init_display(); init_net(); } int main() { Timer timer; Ticker ticker; LED_BUSY_ON; init(); LED_BUSY_OFF; ticker.attach(&isr_timer, 0.1); // Interrupt 10Hz timer.start(); while(1) { // main loop LED_BUSY_ON; pool_net(); __disable_irq(); update_sensor(); __enable_irq(); // create CSV format_str(csv_mesg, csv, sizeof(csv)); pc.printf(csv); write_log(csv); // in/out exec_ilip(1); LED_BUSY_OFF; while (locUpTime % 100 != 0) { pool_net(); wait_ms(100); } // interval (wait) while (timer.read() < interval) { pool_net(); wait_ms(100); // in/out (timer) 1s if (locUpTime % 100 == 0) { exec_ilip(0); } // for debug if (pc.readable()) { int i; i = pc.getc(); if (i == ' ') { break; } else { pc.printf("( %d )\r\n", (int)timer.read()); } } } timer.reset(); } }