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: display.cpp
- Revision:
- 2:a3e5edf84f74
- Parent:
- 1:6c7141895545
--- a/display.cpp Sun Jul 10 15:36:46 2011 +0000 +++ b/display.cpp Wed Aug 24 13:22:32 2011 +0000 @@ -16,21 +16,20 @@ static I2CLEDDisp *leddisp; static I2CLCD *lcd; -static volatile int lcd_flg = 0, leddisp_flg = 0; static volatile int leddisp_freq = 0, leddisp_pos = -4; -static char leddisp_buf[150]; +static char leddisp_buf[FORMAT_STR_SIZE]; #endif void update_display () { #ifdef USE_DISPLAY - char buf[128], tmp[128]; + char buf[FORMAT_STR_SIZE]; - if (leddisp_flg && cfg.getValue("LEDDISP_MESG", tmp, sizeof(tmp))) { - format_str(tmp, leddisp_buf, sizeof(leddisp_buf)); + if (conf.leddisp_mesg[0]) { + format_str(conf.leddisp_mesg, leddisp_buf, sizeof_1(leddisp_buf)); } - if (lcd_flg && cfg.getValue("LCD_MESG", tmp, sizeof(tmp))) { - format_str(tmp, buf, sizeof(buf)); + if (conf.lcd_mesg[0]) { + format_str(conf.lcd_mesg, buf, sizeof_1(buf)); lcd->cls(); lcd->puts(buf); } @@ -42,7 +41,7 @@ int i, addr, len; // LED Display scroll - if (leddisp_flg) { + if (conf.leddisp_mesg[0]) { leddisp_freq ++; if (leddisp_freq > LED_FREQ) { @@ -70,33 +69,19 @@ int init_display () { #ifdef USE_DISPLAY - char buf[128]; - enum I2CLCDType lcdtype = LCD16x2; - enum I2CLCDConfig lcdconf = LCDCFG_3V; - if (cfg.getValue("LCD_MESG", buf, sizeof(buf))) { - if (cfg.getValue("LCD_TYPE", buf, sizeof(buf))) { - lcdtype = (enum I2CLCDType)atoi(buf); - } - if (cfg.getValue("LCD_CONF", buf, sizeof(buf))) { - lcdconf = (enum I2CLCDConfig)atoi(buf); - } - lcd = new I2CLCD(i2c, I2CLCD_ADDR, lcdtype, lcdconf); - if (lcd == NULL) return -1; - lcd_flg = 1; - + if (conf.lcd_mesg[0]) { + lcd = new I2CLCD(i2c, I2CLCD_ADDR, conf.lcdtype, conf.lcdconf); #ifdef DEBUG - printf("LCD: %s\r\n", buf); + printf("LCD: %s\r\n", conf.lcd_mesg); #endif } - if (cfg.getValue("LEDDISP_MESG", buf, sizeof(buf))) { + if (conf.leddisp_mesg[0]) { leddisp = new I2CLEDDisp(i2c); - if (leddisp == NULL) return -1; - leddisp_flg = 1; - strncpy(leddisp_buf, VERSION, sizeof(leddisp_buf)); + strncpy(leddisp_buf, VERSION, sizeof_1(leddisp_buf)); #ifdef DEBUG - printf("LED disp: %s\r\n", buf); + printf("LED disp: %s\r\n", conf.leddisp_mesg); #endif }