@@ -40,7 +40,7 @@ void WundergroundClient::updateConditions(String apiKey, String country, String
40
40
41
41
void WundergroundClient::updateForecast (String apiKey, String country, String city) {
42
42
isForecast = true ;
43
- doUpdate (" /api/" + apiKey + " /forecast10day/q/" + country + " /" + city + " .json" );
43
+ doUpdate (" /api/" + apiKey + " /forecast10day/q/" + country + " /" + city + " .json" );
44
44
}
45
45
46
46
void WundergroundClient::doUpdate (String url) {
@@ -52,18 +52,18 @@ void WundergroundClient::doUpdate(String url) {
52
52
Serial.println (" connection failed" );
53
53
return ;
54
54
}
55
-
55
+
56
56
Serial.print (" Requesting URL: " );
57
57
Serial.println (url);
58
-
58
+
59
59
// This will send the request to the server
60
60
client.print (String (" GET " ) + url + " HTTP/1.1\r\n " +
61
- " Host: api.wunderground.com\r\n " +
61
+ " Host: api.wunderground.com\r\n " +
62
62
" Connection: close\r\n\r\n " );
63
63
while (!client.available ()) {
64
- delay (1000 );
64
+ delay (1000 );
65
65
}
66
-
66
+
67
67
int pos = 0 ;
68
68
boolean isBody = false ;
69
69
char c;
@@ -117,9 +117,9 @@ void WundergroundClient::value(String value) {
117
117
}
118
118
if (currentKey == " icon" ) {
119
119
if (isForecast && !isSimpleForecast && currentForecastPeriod < MAX_FORECAST_PERIODS) {
120
- Serial.println (String (currentForecastPeriod) + " : " + value + " :" + currentParent);
120
+ Serial.println (String (currentForecastPeriod) + " : " + value + " :" + currentParent);
121
121
forecastIcon[currentForecastPeriod] = value;
122
- }
122
+ }
123
123
if (!isForecast) {
124
124
weatherIcon = value;
125
125
}
@@ -146,30 +146,31 @@ void WundergroundClient::value(String value) {
146
146
currentForecastPeriod = value.toInt ();
147
147
}
148
148
if (currentKey == " title" && currentForecastPeriod < MAX_FORECAST_PERIODS) {
149
- Serial.println (String (currentForecastPeriod) + " : " + value);
149
+ Serial.println (String (currentForecastPeriod) + " : " + value);
150
150
forecastTitle[currentForecastPeriod] = value;
151
151
}
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
153
153
// night and day, starting at index 1.
154
154
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
+
157
158
if (currentParent == " high" ) {
158
159
forecastHighTemp[dailyForecastPeriod] = value;
159
160
}
160
161
if (currentParent == " low" ) {
161
162
forecastLowTemp[dailyForecastPeriod] = value;
162
- }
163
+ }
163
164
}
164
- if (currentKey == " celsius" && isMetric && currentForecastPeriod < MAX_FORECAST_PERIODS) {
165
-
165
+ if (currentKey == " celsius" && isMetric && dailyForecastPeriod < MAX_FORECAST_PERIODS) {
166
+
166
167
if (currentParent == " high" ) {
167
168
Serial.println (String (currentForecastPeriod)+ " : " + value);
168
169
forecastHighTemp[dailyForecastPeriod] = value;
169
170
}
170
171
if (currentParent == " low" ) {
171
172
forecastLowTemp[dailyForecastPeriod] = value;
172
- }
173
+ }
173
174
}
174
175
}
175
176
@@ -260,7 +261,7 @@ String WundergroundClient::getTodayIcon() {
260
261
}
261
262
262
263
String WundergroundClient::getForecastIcon (int period) {
263
- return getMeteoconIcon (forecastIcon[period]);
264
+ return getMeteoconIcon (forecastIcon[period]);
264
265
}
265
266
266
267
String WundergroundClient::getForecastTitle (int period) {
@@ -276,48 +277,45 @@ String WundergroundClient::getForecastHighTemp(int period) {
276
277
}
277
278
278
279
String 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
+
319
320
return " )" ;
320
321
}
321
-
322
-
323
-
0 commit comments