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
display.cpp
00001 /* 00002 * Weather Station - mbed Weather Platform 00003 * Copyright (c) 2011 Hiroshi Suga 00004 * Released under the MIT License: http://mbed.org/license/mit 00005 */ 00006 00007 /** @file 00008 * @brief Weather Station 00009 */ 00010 00011 #include "mbed.h" 00012 #include "weather.h" 00013 #ifdef USE_DISPLAY 00014 #include "I2CLEDDisp.h" 00015 #include "I2CLCD.h" 00016 00017 static I2CLEDDisp *leddisp; 00018 static I2CLCD *lcd; 00019 static volatile int leddisp_freq = 0, leddisp_pos = -4; 00020 static char leddisp_buf[FORMAT_STR_SIZE]; 00021 #endif 00022 00023 void update_display () { 00024 #ifdef USE_DISPLAY 00025 char buf[FORMAT_STR_SIZE]; 00026 00027 if (conf.leddisp_mesg[0]) { 00028 format_str(conf.leddisp_mesg, leddisp_buf, sizeof_1(leddisp_buf)); 00029 } 00030 00031 if (conf.lcd_mesg[0]) { 00032 format_str(conf.lcd_mesg, buf, sizeof_1(buf)); 00033 lcd->cls(); 00034 lcd->puts(buf); 00035 } 00036 #endif 00037 } 00038 00039 void pool_display () { 00040 #ifdef USE_DISPLAY 00041 int i, addr, len; 00042 00043 // LED Display scroll 00044 if (conf.leddisp_mesg[0]) { 00045 leddisp_freq ++; 00046 if (leddisp_freq > LED_FREQ) { 00047 00048 len = strlen(leddisp_buf); 00049 leddisp->locate(0, 0); 00050 for (i = 0; i < 4; i ++) { 00051 addr = leddisp_pos + i; 00052 if (addr >= 0 && addr < len) { 00053 leddisp->putc(leddisp_buf[addr]); 00054 } else { 00055 leddisp->putc(' '); 00056 } 00057 } 00058 00059 leddisp_pos ++; 00060 if (leddisp_pos >= len + 4) { 00061 leddisp_pos = -4; 00062 } 00063 00064 leddisp_freq = 0; 00065 } 00066 } 00067 #endif 00068 } 00069 00070 int init_display () { 00071 #ifdef USE_DISPLAY 00072 00073 if (conf.lcd_mesg[0]) { 00074 lcd = new I2CLCD(i2c, I2CLCD_ADDR, conf.lcdtype, conf.lcdconf); 00075 #ifdef DEBUG 00076 printf("LCD: %s\r\n", conf.lcd_mesg); 00077 #endif 00078 } 00079 00080 if (conf.leddisp_mesg[0]) { 00081 leddisp = new I2CLEDDisp(i2c); 00082 strncpy(leddisp_buf, VERSION, sizeof_1(leddisp_buf)); 00083 #ifdef DEBUG 00084 printf("LED disp: %s\r\n", conf.leddisp_mesg); 00085 #endif 00086 } 00087 00088 #endif 00089 return 0; 00090 }
Generated on Wed Jul 13 2022 18:37:47 by 1.7.2