Skip to content

Commit 00d15ea

Browse files
authored
Merge branch 'master' into master
2 parents 33e461d + 8240efa commit 00d15ea

File tree

2 files changed

+84
-65
lines changed

2 files changed

+84
-65
lines changed

WundergroundClient.cpp

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,17 @@ void WundergroundClient::updateForecast(String apiKey, String language, String c
6161
doUpdate("/api/" + apiKey + "/forecast10day/lang:" + language + "/q/" + country + "/" + city + ".json");
6262
}
6363

64+
6465
void WundergroundClient::updateForecastPWS(String apiKey, String language, String pws) {
6566
isForecast = true;
6667
doUpdate("/api/" + apiKey + "/forecast10day/lang:" + language + "/q/pws:" + pws + ".json");
6768
}
6869

70+
void WundergroundClient::updateForecastZMW(String apiKey, String language, String zmwCode) {
71+
isForecast = true;
72+
doUpdate("/api/" + apiKey + "/forecast10day/lang:" + language + "/q/zmw:" + zmwCode + ".json");
73+
}
74+
6975
// JJG added ////////////////////////////////
7076
void WundergroundClient::updateAstronomy(String apiKey, String language, String country, String city) {
7177
isForecast = true;
@@ -200,7 +206,7 @@ void WundergroundClient::key(String key) {
200206
isForecast = false;
201207
isAlerts = true;
202208
}
203-
// end fowlerk add
209+
// end fowlerk add
204210
}
205211

206212
void WundergroundClient::value(String value) {
@@ -278,7 +284,7 @@ void WundergroundClient::value(String value) {
278284
else isPM = false;
279285
char tempHourBuff[3] = ""; // fowlerk add for formatting, 12/22/16
280286
sprintf(tempHourBuff, "%2d", tempHour); // fowlerk add for formatting, 12/22/16
281-
moonriseTime = String(tempHourBuff); // fowlerk add for formatting, 12/22/16
287+
moonriseTime = String(tempHourBuff); // fowlerk add for formatting, 12/22/16
282288
// moonriseTime = value;
283289
}
284290
if (currentKey == "minute") {
@@ -294,7 +300,7 @@ void WundergroundClient::value(String value) {
294300
if (currentKey == "hour") {
295301
char tempHourBuff[3] = ""; // fowlerk add for formatting, 12/22/16
296302
sprintf(tempHourBuff, "%2d", value.toInt()); // fowlerk add for formatting, 12/22/16
297-
moonsetTime = String(tempHourBuff); // fowlerk add for formatting, 12/22/16
303+
moonsetTime = String(tempHourBuff); // fowlerk add for formatting, 12/22/16
298304
}
299305
if (currentKey == "minute") {
300306
char tempMinBuff[3] = ""; // fowlerk add for formatting, 12/22/16
@@ -303,8 +309,12 @@ void WundergroundClient::value(String value) {
303309
}
304310
}
305311

306-
if (currentKey == "wind_mph") {
307-
windSpeed = value;
312+
if (currentKey == "wind_mph" && !isMetric) {
313+
windSpeed = value + "mph";
314+
}
315+
316+
if (currentKey == "wind_kph" && isMetric) {
317+
windSpeed = value + "km/h";
308318
}
309319

310320
if (currentKey == "wind_dir") {
@@ -313,15 +323,19 @@ void WundergroundClient::value(String value) {
313323

314324
// end JJG add ////////////////////////////////////////////////////////////////////
315325

316-
if (currentKey == "observation_time_rfc822") {
326+
if (currentKey == "local_time_rfc822") {
317327
date = value.substring(0, 16);
318328
}
319-
// Begin add, fowlerk...04-Dec-2016
329+
330+
if (currentKey == "observation_time_rfc822") {
331+
observationDate = value.substring(0, 16);
332+
}
333+
// Begin add, fowlerk...04-Dec-2016
320334
if (currentKey == "observation_time") {
321335
observationTime = value;
322336
}
323-
// end add, fowlerk
324-
337+
// end add, fowlerk
338+
325339
if (currentKey == "temp_f" && !isMetric) {
326340
currentTemp = value;
327341
}
@@ -354,15 +368,15 @@ void WundergroundClient::value(String value) {
354368
if (currentKey == "feelslike_f" && !isMetric) {
355369
feelslike = value;
356370
}
357-
371+
358372
if (currentKey == "feelslike_c" && isMetric) {
359373
feelslike = value;
360374
}
361-
375+
362376
if (currentKey == "UV") {
363377
UV = value;
364378
}
365-
379+
366380
// Active alerts...added 18-Dec-2016
367381
if (currentKey == "type" && isAlerts) {
368382
activeAlertsCnt++;
@@ -426,9 +440,9 @@ void WundergroundClient::value(String value) {
426440
activeAlertsAttribution[currentAlert-1].replace("</a>","");
427441
activeAlertsAttribution[currentAlert-1].replace("/'>"," ");
428442
}
429-
443+
430444
// end fowlerk add
431-
445+
432446
if (currentKey == "dewpoint_f" && !isMetric) {
433447
dewPoint = value;
434448
}
@@ -447,7 +461,7 @@ void WundergroundClient::value(String value) {
447461
// Modified below line to add check to ensure we are processing the 10-day forecast
448462
// before setting the forecastTitle (day of week of the current forecast day).
449463
// (The keyword title is used in both the current observation and the 10-day forecast.)
450-
// Modified by fowlerk
464+
// Modified by fowlerk
451465
// if (currentKey == "title" && currentForecastPeriod < MAX_FORECAST_PERIODS) { // Removed, fowlerk
452466
if (currentKey == "title" && isForecast && currentForecastPeriod < MAX_FORECAST_PERIODS) {
453467
Serial.println(String(currentForecastPeriod) + ": " + value);
@@ -463,13 +477,13 @@ void WundergroundClient::value(String value) {
463477
forecastText[currentForecastPeriod] = value;
464478
}
465479
// end fowlerk add, 12/3/16
466-
480+
467481
// Added PoP (probability of precipitation) key following...fowlerk, 12/22/16
468482
if (currentKey == "pop" && isForecast && currentForecastPeriod < MAX_FORECAST_PERIODS) {
469483
PoP[currentForecastPeriod] = value;
470484
}
471485
// end fowlerk add, 12/22/16
472-
486+
473487
// The detailed forecast period has only one forecast per day with low/high for both
474488
// night and day, starting at index 1.
475489
int dailyForecastPeriod = (currentForecastPeriod - 1) * 2;
@@ -502,19 +516,19 @@ void WundergroundClient::value(String value) {
502516
currentForecastPeriod = 0;
503517
}
504518
forecastMonth[currentForecastPeriod] = value;
505-
}
519+
}
506520

507521
if (currentKey == "day" && isSimpleForecast && currentForecastPeriod < MAX_FORECAST_PERIODS) {
508522
// Added by fowlerk to handle transition from txtforecast to simpleforecast, as
509523
// the key "period" doesn't appear until after some of the key values needed and is
510524
// used as an array index.
511525
if (isSimpleForecast && currentForecastPeriod == 19) {
512526
currentForecastPeriod = 0;
513-
}
527+
}
514528
forecastDay[currentForecastPeriod] = value;
515529
}
516530
// end fowlerk add
517-
531+
518532
}
519533

520534
void WundergroundClient::endArray() {
@@ -575,6 +589,9 @@ String WundergroundClient::getSeconds() {
575589
String WundergroundClient::getDate() {
576590
return date;
577591
}
592+
String WundergroundClient::getObservationDate() {
593+
return observationDate;
594+
}
578595
long WundergroundClient::getCurrentEpoch() {
579596
return localEpoc + ((millis() - localMillisAtUpdate) / 1000);
580597
}
@@ -725,17 +742,17 @@ String WundergroundClient::getForecastHighTemp(int period) {
725742
}
726743
// fowlerk added...
727744
String WundergroundClient::getForecastDay(int period) {
728-
// Serial.print("Day period: "); Serial.println(period);
745+
// Serial.print("Day period: "); Serial.println(period);
729746
return forecastDay[period];
730747
}
731748

732749
String WundergroundClient::getForecastMonth(int period) {
733-
// Serial.print("Month period: "); Serial.println(period);
750+
// Serial.print("Month period: "); Serial.println(period);
734751
return forecastMonth[period];
735752
}
736753

737754
String WundergroundClient::getForecastText(int period) {
738-
// Serial.print("Forecast period: "); Serial.println(period);
755+
// Serial.print("Forecast period: "); Serial.println(period);
739756
return forecastText[period];
740757
}
741758

@@ -788,4 +805,4 @@ String WundergroundClient::getMeteoconIcon(String iconText) {
788805
if (iconText == "nt_tstorms") return "&";
789806

790807
return ")";
791-
}
808+
}

WundergroundClient.h

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class WundergroundClient: public JsonListener {
4141
int gmtOffset = 1;
4242
long localMillisAtUpdate;
4343
String date = "-";
44+
String observationDate = "-";
4445
boolean isMetric = true;
4546
String currentTemp;
4647
// JJG added ... ////////////////////////////////// define returns /////////////////////////////////
@@ -65,7 +66,7 @@ class WundergroundClient: public JsonListener {
6566
String UV;
6667
String observationTime; // fowlerk add, 04-Dec-2016
6768
// end fowlerk add
68-
69+
6970
void doUpdate(String url);
7071

7172
// forecast
@@ -106,17 +107,18 @@ class WundergroundClient: public JsonListener {
106107
void updateConditionsPWS(String apiKey, String language, String pws);
107108
void updateForecast(String apiKey, String language, String country, String city);
108109
void updateForecastPWS(String apiKey, String language, String pws);
110+
void updateForecastZMW(String apiKey, String language, String zmwCode);
109111
void updateAstronomy(String apiKey, String language, String country, String city);
110112
void updateAstronomyPWS(String apiKey, String language, String pws);
111-
void updateAlerts(String apiKey, String language, String country, String city); // Added by fowlerk, 18-Dec-2016
112-
void updateAlertsPWS(String apiKey, String language, String country, String pws);
113+
void updateAlerts(String apiKey, String language, String country, String city); // Added by fowlerk, 18-Dec-2016
114+
void updateAlertsPWS(String apiKey, String language, String country, String pws);
113115
void initMetric(boolean isMetric); // Added by fowlerk, 12/22/16, as an option to change metric setting other than at instantiation
114-
115116
// JJG added
116117
String getHours();
117118
String getMinutes();
118119
String getSeconds();
119120
String getDate();
121+
String getObservationDate();
120122
// JJG added ... ///////////////////function name to string ////////////////////////////
121123
String getMoonPctIlum();
122124
String getMoonAge();
@@ -147,13 +149,13 @@ class WundergroundClient: public JsonListener {
147149
String getDewPoint();
148150

149151
String getPrecipitationToday();
150-
// fowlerk added...
151-
String getFeelsLike();
152-
153-
String getUV();
154-
155-
String getObservationTime(); // fowlerk add, 04-Dec-2016
156-
// end fowlerk add
152+
// fowlerk added...
153+
String getFeelsLike();
154+
155+
String getUV();
156+
157+
String getObservationTime(); // fowlerk add, 04-Dec-2016
158+
// end fowlerk add
157159

158160
String getForecastIcon(int period);
159161

@@ -162,36 +164,36 @@ class WundergroundClient: public JsonListener {
162164
String getForecastLowTemp(int period);
163165

164166
String getForecastHighTemp(int period);
165-
// fowlerk added...
166-
String getForecastDay(int period);
167-
168-
String getForecastMonth(int period);
169-
170-
String getForecastText(int period);
171-
172-
String getPoP(int period);
173-
174-
int getActiveAlertsCnt();
175-
176-
String getActiveAlerts(int alertIndex);
177-
178-
String getActiveAlertsText(int alertIndex);
179-
180-
String getActiveAlertsMessage(int alertIndex);
181-
182-
bool getActiveAlertsMessageTrunc(int alertIndex);
183-
184-
String getActiveAlertsStart(int alertIndex);
185-
186-
String getActiveAlertsEnd(int alertIndex);
187-
188-
String getActiveAlertsPhenomena(int alertIndex);
189-
190-
String getActiveAlertsSignificance(int alertIndex);
191-
192-
String getActiveAlertsAttribution(int alertIndex);
193-
194-
// end fowlerk add
167+
// fowlerk added...
168+
String getForecastDay(int period);
169+
170+
String getForecastMonth(int period);
171+
172+
String getForecastText(int period);
173+
174+
String getPoP(int period);
175+
176+
int getActiveAlertsCnt();
177+
178+
String getActiveAlerts(int alertIndex);
179+
180+
String getActiveAlertsText(int alertIndex);
181+
182+
String getActiveAlertsMessage(int alertIndex);
183+
184+
bool getActiveAlertsMessageTrunc(int alertIndex);
185+
186+
String getActiveAlertsStart(int alertIndex);
187+
188+
String getActiveAlertsEnd(int alertIndex);
189+
190+
String getActiveAlertsPhenomena(int alertIndex);
191+
192+
String getActiveAlertsSignificance(int alertIndex);
193+
194+
String getActiveAlertsAttribution(int alertIndex);
195+
196+
// end fowlerk add
195197

196198
virtual void whitespace(char c);
197199

0 commit comments

Comments
 (0)