@@ -40,7 +40,7 @@ void WundergroundClient::updateConditions(String apiKey, String country, String
4040
4141void WundergroundClient::updateForecast (String apiKey, String country, String city) {
4242 isForecast = true ;
43- doUpdate (" /api/" + apiKey + " /forecast10day/q/" + country + " /" + city + " .json" );
43+ doUpdate (" /api/" + apiKey + " /forecast10day/q/" + country + " /" + city + " .json" );
4444}
4545
4646void WundergroundClient::doUpdate (String url) {
@@ -52,18 +52,18 @@ void WundergroundClient::doUpdate(String url) {
5252 Serial.println (" connection failed" );
5353 return ;
5454 }
55-
55+
5656 Serial.print (" Requesting URL: " );
5757 Serial.println (url);
58-
58+
5959 // This will send the request to the server
6060 client.print (String (" GET " ) + url + " HTTP/1.1\r\n " +
61- " Host: api.wunderground.com\r\n " +
61+ " Host: api.wunderground.com\r\n " +
6262 " Connection: close\r\n\r\n " );
6363 while (!client.available ()) {
64- delay (1000 );
64+ delay (1000 );
6565 }
66-
66+
6767 int pos = 0 ;
6868 boolean isBody = false ;
6969 char c;
@@ -117,9 +117,9 @@ void WundergroundClient::value(String value) {
117117 }
118118 if (currentKey == " icon" ) {
119119 if (isForecast && !isSimpleForecast && currentForecastPeriod < MAX_FORECAST_PERIODS) {
120- Serial.println (String (currentForecastPeriod) + " : " + value + " :" + currentParent);
120+ Serial.println (String (currentForecastPeriod) + " : " + value + " :" + currentParent);
121121 forecastIcon[currentForecastPeriod] = value;
122- }
122+ }
123123 if (!isForecast) {
124124 weatherIcon = value;
125125 }
@@ -146,30 +146,31 @@ void WundergroundClient::value(String value) {
146146 currentForecastPeriod = value.toInt ();
147147 }
148148 if (currentKey == " title" && currentForecastPeriod < MAX_FORECAST_PERIODS) {
149- Serial.println (String (currentForecastPeriod) + " : " + value);
149+ Serial.println (String (currentForecastPeriod) + " : " + value);
150150 forecastTitle[currentForecastPeriod] = value;
151151 }
152- // The detailed forecast period has only one forecast per day with low/high for both
152+ // The detailed forecast period has only one forecast per day with low/high for both
153153 // night and day, starting at index 1.
154154 int dailyForecastPeriod = (currentForecastPeriod - 1 ) * 2 ;
155- if (currentKey == " fahrenheit" && !isMetric && currentForecastPeriod < MAX_FORECAST_PERIODS) {
156-
155+
156+ if (currentKey == " fahrenheit" && !isMetric && dailyForecastPeriod < MAX_FORECAST_PERIODS) {
157+
157158 if (currentParent == " high" ) {
158159 forecastHighTemp[dailyForecastPeriod] = value;
159160 }
160161 if (currentParent == " low" ) {
161162 forecastLowTemp[dailyForecastPeriod] = value;
162- }
163+ }
163164 }
164- if (currentKey == " celsius" && isMetric && currentForecastPeriod < MAX_FORECAST_PERIODS) {
165-
165+ if (currentKey == " celsius" && isMetric && dailyForecastPeriod < MAX_FORECAST_PERIODS) {
166+
166167 if (currentParent == " high" ) {
167168 Serial.println (String (currentForecastPeriod)+ " : " + value);
168169 forecastHighTemp[dailyForecastPeriod] = value;
169170 }
170171 if (currentParent == " low" ) {
171172 forecastLowTemp[dailyForecastPeriod] = value;
172- }
173+ }
173174 }
174175}
175176
@@ -260,7 +261,7 @@ String WundergroundClient::getTodayIcon() {
260261}
261262
262263String WundergroundClient::getForecastIcon (int period) {
263- return getMeteoconIcon (forecastIcon[period]);
264+ return getMeteoconIcon (forecastIcon[period]);
264265}
265266
266267String WundergroundClient::getForecastTitle (int period) {
@@ -276,48 +277,45 @@ String WundergroundClient::getForecastHighTemp(int period) {
276277}
277278
278279String WundergroundClient::getMeteoconIcon (String iconText) {
279- if (iconText == " chanceflurries" ) return " F" ;
280- if (iconText == " chancerain" ) return " Q" ;
281- if (iconText == " chancesleet" ) return " W" ;
282- if (iconText == " chancesnow" ) return " V" ;
283- if (iconText == " chancetstorms" ) return " S" ;
284- if (iconText == " clear" ) return " B" ;
285- if (iconText == " cloudy" ) return " Y" ;
286- if (iconText == " flurries" ) return " F" ;
287- if (iconText == " fog" ) return " M" ;
288- if (iconText == " hazy" ) return " E" ;
289- if (iconText == " mostlycloudy" ) return " Y" ;
290- if (iconText == " mostlysunny" ) return " H" ;
291- if (iconText == " partlycloudy" ) return " H" ;
292- if (iconText == " partlysunny" ) return " J" ;
293- if (iconText == " sleet" ) return " W" ;
294- if (iconText == " rain" ) return " R" ;
295- if (iconText == " snow" ) return " W" ;
296- if (iconText == " sunny" ) return " B" ;
297- if (iconText == " tstorms" ) return " 0" ;
298-
299- if (iconText == " nt_chanceflurries" ) return " F" ;
300- if (iconText == " nt_chancerain" ) return " 7" ;
301- if (iconText == " nt_chancesleet" ) return " #" ;
302- if (iconText == " nt_chancesnow" ) return " #" ;
303- if (iconText == " nt_chancetstorms" ) return " &" ;
304- if (iconText == " nt_clear" ) return " 2" ;
305- if (iconText == " nt_cloudy" ) return " Y" ;
306- if (iconText == " nt_flurries" ) return " 9" ;
307- if (iconText == " nt_fog" ) return " M" ;
308- if (iconText == " nt_hazy" ) return " E" ;
309- if (iconText == " nt_mostlycloudy" ) return " 5" ;
310- if (iconText == " nt_mostlysunny" ) return " 3" ;
311- if (iconText == " nt_partlycloudy" ) return " 4" ;
312- if (iconText == " nt_partlysunny" ) return " 4" ;
313- if (iconText == " nt_sleet" ) return " 9" ;
314- if (iconText == " nt_rain" ) return " 7" ;
315- if (iconText == " nt_snow" ) return " #" ;
316- if (iconText == " nt_sunny" ) return " 4" ;
317- if (iconText == " nt_tstorms" ) return " &" ;
318-
280+ if (iconText == " chanceflurries" ) return " F" ;
281+ if (iconText == " chancerain" ) return " Q" ;
282+ if (iconText == " chancesleet" ) return " W" ;
283+ if (iconText == " chancesnow" ) return " V" ;
284+ if (iconText == " chancetstorms" ) return " S" ;
285+ if (iconText == " clear" ) return " B" ;
286+ if (iconText == " cloudy" ) return " Y" ;
287+ if (iconText == " flurries" ) return " F" ;
288+ if (iconText == " fog" ) return " M" ;
289+ if (iconText == " hazy" ) return " E" ;
290+ if (iconText == " mostlycloudy" ) return " Y" ;
291+ if (iconText == " mostlysunny" ) return " H" ;
292+ if (iconText == " partlycloudy" ) return " H" ;
293+ if (iconText == " partlysunny" ) return " J" ;
294+ if (iconText == " sleet" ) return " W" ;
295+ if (iconText == " rain" ) return " R" ;
296+ if (iconText == " snow" ) return " W" ;
297+ if (iconText == " sunny" ) return " B" ;
298+ if (iconText == " tstorms" ) return " 0" ;
299+
300+ if (iconText == " nt_chanceflurries" ) return " F" ;
301+ if (iconText == " nt_chancerain" ) return " 7" ;
302+ if (iconText == " nt_chancesleet" ) return " #" ;
303+ if (iconText == " nt_chancesnow" ) return " #" ;
304+ if (iconText == " nt_chancetstorms" ) return " &" ;
305+ if (iconText == " nt_clear" ) return " 2" ;
306+ if (iconText == " nt_cloudy" ) return " Y" ;
307+ if (iconText == " nt_flurries" ) return " 9" ;
308+ if (iconText == " nt_fog" ) return " M" ;
309+ if (iconText == " nt_hazy" ) return " E" ;
310+ if (iconText == " nt_mostlycloudy" ) return " 5" ;
311+ if (iconText == " nt_mostlysunny" ) return " 3" ;
312+ if (iconText == " nt_partlycloudy" ) return " 4" ;
313+ if (iconText == " nt_partlysunny" ) return " 4" ;
314+ if (iconText == " nt_sleet" ) return " 9" ;
315+ if (iconText == " nt_rain" ) return " 7" ;
316+ if (iconText == " nt_snow" ) return " #" ;
317+ if (iconText == " nt_sunny" ) return " 4" ;
318+ if (iconText == " nt_tstorms" ) return " &" ;
319+
319320 return " )" ;
320321}
321-
322-
323-
0 commit comments