adfa
Dependencies: 4DGL-uLCD-SE NetServices mbed spxml
Fork of weather_Nokia_LCD_display_yahoo by
Diff: main.cpp
- Revision:
- 3:9e55847f25c4
- Parent:
- 2:b14f99568253
- Child:
- 4:22120d759a19
--- a/main.cpp Mon Apr 25 16:22:39 2016 +0000 +++ b/main.cpp Wed Apr 27 20:40:34 2016 +0000 @@ -12,8 +12,6 @@ //NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type uLCD_4DGL lcd(p28,p27,p29); -DigitalIn but1(p19); -DigitalIn but2(p20); EthernetNetIf eth; HTTPClient http; HTTPResult result; @@ -36,52 +34,18 @@ lcd.printf("%s",condition->getAttrValue("text")); //Print the termperature (in degrees Celcius) lcd.locate(0,4); - lcd.printf("%sC",condition->getAttrValue("temp")); - //Print the date and time + lcd.printf("%sF",condition->getAttrValue("temp")); + /*//Print the date and time lcd.locate(0,5); lcd.printf("%s",condition->getAttrValue("date")); + */ } -int main() { +int weather() { // the eth and HTTP code has be taken directly from the HTTPStream documentation page // see http://mbed.org/cookbook/HTTP-Client-Data-Containers lcd.cls(); - // string arrays associating cities with their codes for the yahoo! API - string cities[5] = { "Atlanta", "Houston", "New York", "Seattle", "Sunnyvale" }; - string codes[5] = { "2357024", "2424766", "2459115", "2490383", "2442047" }; - - string head = "http://weather.yahooapis.com/forecastrss?w="; - //Display the cities to choose from - for(int i = 0; i < 5; i++){ - lcd.locate(1, i); - lcd.printf("%i: %s", i+1, cities[i]); - } - - int curr = 0; - int accept = but1, select = but2, pushed = 0; - //This while loop handles selection of cities for display. - while(accept == 0){ - lcd.locate(0, curr); - lcd.printf(" "); - //The next two if statements check to see if the button has been pushed, and then cycles through the selection choices as appropriate. - if(select == 1){ - pushed = 1; - } - if((select == 0)&&(pushed == 1)){ - pushed = 0; - curr = (curr + 1)%5; - } - lcd.locate(0, curr); - lcd.printf(">"); - accept = but1; select = but2; - } - //Concatenate the city code for use by the Yahoo! API - head += codes[curr]; - head += "&u=c"; - - lcd.cls(); - lcd.locate(0,2); lcd.printf("net setup"); lcd.locate(0,3); @@ -117,16 +81,16 @@ } SP_XmlHandle rootHandle( parser.getDocument()->getRootElement() ); - SP_XmlElementNode * child2 = rootHandle.getChild( "channel" ) + SP_XmlElementNode * child2 = rootHandle.getChild( "results" ).getChild( "channel" ) .toElement(); - lcd.printf(BigBuf); + //lcd.printf(BigBuf); if ( child2 ) { - parseWeather(child2, cities[curr]); //parses XML "current-conditions" info + parseWeather(child2, "Atlanta"); //parses XML "current-conditions" info } - + if ( NULL != parser.getError() ) { lcd.printf( "\n error: %s\n", parser.getError() ); } -} +} \ No newline at end of file