From ca94f3472025b8dba46a2cdbda5bfe062cc1663a Mon Sep 17 00:00:00 2001
From: Chrome Legion
Date: Wed, 22 Aug 2018 21:57:47 -0700
Subject: [PATCH 1/4] Qrome - updated version number to 2.4
---
marquee/marquee.ino | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/marquee/marquee.ino b/marquee/marquee.ino
index 3e28ee5..052b706 100644
--- a/marquee/marquee.ino
+++ b/marquee/marquee.ino
@@ -27,7 +27,7 @@ SOFTWARE.
#include "Settings.h"
-#define VERSION "2.3"
+#define VERSION "2.4"
#define HOSTNAME "CLOCK-"
#define CONFIG "/conf.txt"
From 82acf610a9caf69c2f711084d67c48744f52fbb0 Mon Sep 17 00:00:00 2001
From: Chrome Legion
Date: Thu, 30 Aug 2018 20:29:07 -0700
Subject: [PATCH 2/4] Qrome updated some of the News Story character cleaning
---
marquee/NewsApiClient.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/marquee/NewsApiClient.cpp b/marquee/NewsApiClient.cpp
index 5c091d7..d8f5ad1 100644
--- a/marquee/NewsApiClient.cpp
+++ b/marquee/NewsApiClient.cpp
@@ -173,11 +173,15 @@ String NewsApiClient::cleanText(String text) {
text.replace("È", "E");
text.replace("Ë", "E");
text.replace("Ô", "O");
- text.replace("Ö", "O");
+ text.replace("Ö", "Oe");
+ text.replace("ö", "oe");
text.replace("œ", "oe");
text.replace("Œ", "OE");
text.replace("Ù", "U");
text.replace("Û", "U");
- text.replace("Ü", "U");
+ text.replace("Ü", "Ue");
+ text.replace("ü", "ue");
+ text.replace("Ä", "Ae");
+ text.replace("ä", "ae");
return text;
}
From e949840d739e35be11e79d280660a49943183cf1 Mon Sep 17 00:00:00 2001
From: Chrome Legion
Date: Sun, 28 Oct 2018 23:02:29 -0700
Subject: [PATCH 3/4] Qrome - updated with DST as an option and added Day of
the week
---
marquee/GeoNamesClient.cpp | 10 ++++++---
marquee/GeoNamesClient.h | 5 +++--
marquee/OpenWeatherMapClient.cpp | 35 ++++++++++++++++++++++++++++++++
marquee/OpenWeatherMapClient.h | 1 +
marquee/Settings.h | 1 +
marquee/TimeClient.cpp | 2 ++
marquee/TimeClient.h | 1 -
marquee/marquee.ino | 25 +++++++++++++++++------
8 files changed, 68 insertions(+), 12 deletions(-)
diff --git a/marquee/GeoNamesClient.cpp b/marquee/GeoNamesClient.cpp
index c063659..97c9f5a 100644
--- a/marquee/GeoNamesClient.cpp
+++ b/marquee/GeoNamesClient.cpp
@@ -23,14 +23,15 @@ SOFTWARE.
#include "GeoNamesClient.h"
-GeoNamesClient::GeoNamesClient(String UserName, String lat, String lon) {
- updateClient(UserName, lat, lon);
+GeoNamesClient::GeoNamesClient(String UserName, String lat, String lon, boolean useDst) {
+ updateClient(UserName, lat, lon, useDst);
}
-void GeoNamesClient::updateClient(String UserName, String lat, String lon) {
+void GeoNamesClient::updateClient(String UserName, String lat, String lon, boolean useDst) {
myLat = lat;
myLon = lon;
myUserName = UserName;
+ isDst = useDst;
}
float GeoNamesClient::getTimeOffset() {
@@ -79,6 +80,9 @@ float GeoNamesClient::getTimeOffset() {
DynamicJsonBuffer json_buf;
JsonObject& root = json_buf.parseObject(jsonArray);
String offset = (const char*)root["dstOffset"];
+ if (!isDst) {
+ offset = (const char*)root["rawOffset"];
+ }
// Sample time: "2018-03-19 21:22"
datetime = (const char*)root["time"];
Serial.println("rawOffset for " + String((const char*)root["timezoneId"]) + " is: " + offset);
diff --git a/marquee/GeoNamesClient.h b/marquee/GeoNamesClient.h
index 6a99c36..82d0dbf 100644
--- a/marquee/GeoNamesClient.h
+++ b/marquee/GeoNamesClient.h
@@ -31,6 +31,7 @@ class GeoNamesClient {
String myLat = "";
String myLon = "";
String myUserName = "";
+ boolean isDst = true; // Daylight Savings Time
int hours = 0;
int minutes = 0;
@@ -39,8 +40,8 @@ class GeoNamesClient {
const char* servername = "api.geonames.org"; // remote server we will connect to
public:
- GeoNamesClient(String UserName, String lat, String lon);
- void updateClient(String UserName, String lat, String lon);
+ GeoNamesClient(String UserName, String lat, String lon, boolean useDst);
+ void updateClient(String UserName, String lat, String lon, boolean useDst);
float getTimeOffset();
String getHours();
String getMinutes();
diff --git a/marquee/OpenWeatherMapClient.cpp b/marquee/OpenWeatherMapClient.cpp
index bbd8074..a5ce8f3 100644
--- a/marquee/OpenWeatherMapClient.cpp
+++ b/marquee/OpenWeatherMapClient.cpp
@@ -228,6 +228,41 @@ String OpenWeatherMapClient::getError() {
return weathers[0].error;
}
+String OpenWeatherMapClient::getWeekDay(int index, float offset) {
+ String rtnValue = "";
+ long epoc = weathers[index].dt.toInt();
+ long day = 0;
+ if (epoc != 0) {
+ day = (((epoc + (3600 * (int)offset)) / 86400) + 4) % 7;
+ switch (day) {
+ case 0:
+ rtnValue = "Sunday";
+ break;
+ case 1:
+ rtnValue = "Monday";
+ break;
+ case 2:
+ rtnValue = "Tuesday";
+ break;
+ case 3:
+ rtnValue = "Wednesday";
+ break;
+ case 4:
+ rtnValue = "Thursday";
+ break;
+ case 5:
+ rtnValue = "Friday";
+ break;
+ case 6:
+ rtnValue = "Saturday";
+ break;
+ default:
+ break;
+ }
+ }
+ return rtnValue;
+}
+
String OpenWeatherMapClient::getWeatherIcon(int index)
{
int id = getWeatherId(index).toInt();
diff --git a/marquee/OpenWeatherMapClient.h b/marquee/OpenWeatherMapClient.h
index 20badbd..0f7b442 100644
--- a/marquee/OpenWeatherMapClient.h
+++ b/marquee/OpenWeatherMapClient.h
@@ -81,5 +81,6 @@ class OpenWeatherMapClient {
String getMyCityIDs();
String getWeatherIcon(int index);
String getError();
+ String getWeekDay(int index, float offset);
};
diff --git a/marquee/Settings.h b/marquee/Settings.h
index 2945dea..43aa6fb 100644
--- a/marquee/Settings.h
+++ b/marquee/Settings.h
@@ -64,6 +64,7 @@ int CityIDs[] = { 5304391 }; //Only USE ONE for weather marquee
String marqueeMessage = "";
boolean IS_METRIC = false; // false = Imperial and true = Metric
boolean IS_24HOUR = false; // 23:00 millitary 24 hour clock
+boolean IS_DST = true; // Does your TimeZone use Daylight Savings Time (DST)?
const int WEBSERVER_PORT = 80; // The port you can access this device on over HTTP
const boolean WEBSERVER_ENABLED = true; // Device will provide a web interface via http://[ip]:[port]/
boolean IS_BASIC_AUTH = true; // Use Basic Authorization for Configuration security on Web Interface
diff --git a/marquee/TimeClient.cpp b/marquee/TimeClient.cpp
index 84d7f1d..967e4f2 100644
--- a/marquee/TimeClient.cpp
+++ b/marquee/TimeClient.cpp
@@ -150,3 +150,5 @@ long TimeClient::getCurrentEpoch() {
long TimeClient::getCurrentEpochWithUtcOffset() {
return round(getCurrentEpoch() + 3600 * myUtcOffset + 86400L) % 86400L;
}
+
+
diff --git a/marquee/TimeClient.h b/marquee/TimeClient.h
index ee36ba5..a75e52e 100644
--- a/marquee/TimeClient.h
+++ b/marquee/TimeClient.h
@@ -57,6 +57,5 @@ class TimeClient {
String getAmPmFormattedTime();
long getCurrentEpoch();
long getCurrentEpochWithUtcOffset();
-
};
diff --git a/marquee/marquee.ino b/marquee/marquee.ino
index 052b706..f66731d 100644
--- a/marquee/marquee.ino
+++ b/marquee/marquee.ino
@@ -69,7 +69,7 @@ boolean displayOn = true;
boolean timeOffsetFetched = false;
// GeoNames
-GeoNamesClient geoNames(GEONAMES_USER, "", "");
+GeoNamesClient geoNames(GEONAMES_USER, "", "", IS_DST);
// News Client
NewsApiClient newsClient(NEWS_API_KEY, NEWS_SOURCE);
@@ -107,7 +107,8 @@ String CHANGE_FORM1 = "
"
" Display Humidity
"
" Display Wind
"
- " Use 24 Hour Clock (military time)
";
+ " Use 24 Hour Clock (military time)
"
+ " Use DST (Daylight Savings Time)
";
String CHANGE_FORM2 = " Display Advice
"
""
@@ -308,7 +309,7 @@ void loop() {
if (timeClient.getHours() == "00" && timeClient.getMinutes() == "00" && timeClient.getSeconds() == "00") {
// Exactly Midnight -- fetch a new geoNames for updating the Date and time offset
- geoNames.updateClient(GEONAMES_USER, weatherClient.getLat(0), weatherClient.getLon(0));
+ geoNames.updateClient(GEONAMES_USER, weatherClient.getLat(0), weatherClient.getLon(0), IS_DST);
UtcOffset = geoNames.getTimeOffset();
}
@@ -343,6 +344,7 @@ void loop() {
msg += " ";
if (SHOW_DATE) {
+ msg += weatherClient.getWeekDay(0, UtcOffset) + ", ";
msg += geoNames.getMonthName() + " " + geoNames.getDay(false) + " ";
}
if (SHOW_CITY) {
@@ -489,6 +491,7 @@ void handleLocations() {
CityIDs[0] = server.arg("city1").toInt();
ADVICE_ENABLED = server.hasArg("displayadvice");
IS_24HOUR = server.hasArg("is24hour");
+ IS_DST = server.hasArg("isDST");
SHOW_DATE = server.hasArg("showdate");
SHOW_CITY = server.hasArg("showcity");
SHOW_CONDITION = server.hasArg("showcondition");
@@ -744,6 +747,11 @@ void handleConfigure() {
is24hourChecked = "checked='checked'";
}
form.replace("%IS_24HOUR_CHECKED%", is24hourChecked);
+ String isDstChecked = "";
+ if (IS_DST) {
+ isDstChecked = "checked='checked'";
+ }
+ form.replace("%IS_DST_CHECKED%", isDstChecked);
String checked = "";
if (IS_METRIC) {
checked = "checked='checked'";
@@ -849,7 +857,7 @@ void getWeatherData() //client function to send/receive GET request data.
// we need to get offsets
centerPrint("....");
timeOffsetFetched = true;
- geoNames.updateClient(GEONAMES_USER, weatherClient.getLat(0), weatherClient.getLon(0));
+ geoNames.updateClient(GEONAMES_USER, weatherClient.getLat(0), weatherClient.getLon(0), IS_DST);
UtcOffset = geoNames.getTimeOffset();
timeClient.setUtcOffset(UtcOffset);
}
@@ -979,7 +987,7 @@ void displayWeatherData() {
}
timeClient.setUtcOffset(getTimeOffset());
- String time = geoNames.getMonthName() + " " + geoNames.getDay(false) + ", " + timeClient.getAmPmFormattedTime();
+ String time = weatherClient.getWeekDay(0, UtcOffset) + ", " + geoNames.getMonthName() + " " + geoNames.getDay(false) + ", " + timeClient.getAmPmFormattedTime();
Serial.println(weatherClient.getCity(0));
Serial.println(weatherClient.getCondition(0));
@@ -1071,7 +1079,7 @@ float getTimeOffset() {
// we need to get offsets
timeOffsetFetched = true;
- geoNames.updateClient(GEONAMES_USER, weatherClient.getLat(0), weatherClient.getLon(0));
+ geoNames.updateClient(GEONAMES_USER, weatherClient.getLat(0), weatherClient.getLon(0), IS_DST);
UtcOffset = geoNames.getTimeOffset();
return UtcOffset;
@@ -1218,6 +1226,7 @@ String writeCityIds() {
f.println("newsApiKey=" + NEWS_API_KEY);
f.println("isAdvice=" + String(ADVICE_ENABLED));
f.println("is24hour=" + String(IS_24HOUR));
+ f.println("isDST=" + String(IS_DST));
f.println("wideclockformat=" + Wide_Clock_Style);
f.println("isMetric=" + String(IS_METRIC));
f.println("refreshRate=" + String(minutesBetweenDataRefresh));
@@ -1283,6 +1292,10 @@ void readCityIds() {
IS_24HOUR = line.substring(line.lastIndexOf("is24hour=") + 9).toInt();
Serial.println("IS_24HOUR=" + String(IS_24HOUR));
}
+ if (line.indexOf("isDST=") >= 0) {
+ IS_DST = line.substring(line.lastIndexOf("isDST=") + 6).toInt();
+ Serial.println("IS_DST=" + String(IS_DST));
+ }
if (line.indexOf("wideclockformat=") >= 0) {
Wide_Clock_Style = line.substring(line.lastIndexOf("wideclockformat=") + 16);
Wide_Clock_Style.trim();
From 4e6dcb3f1caac58d0994d519c353b2f24827bfa2 Mon Sep 17 00:00:00 2001
From: David Payne
Date: Mon, 29 Oct 2018 16:50:02 -0700
Subject: [PATCH 4/4] Qrome - updated to use gmtOffset and not rawOffset
---
marquee/GeoNamesClient.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/marquee/GeoNamesClient.cpp b/marquee/GeoNamesClient.cpp
index 97c9f5a..9dae47f 100644
--- a/marquee/GeoNamesClient.cpp
+++ b/marquee/GeoNamesClient.cpp
@@ -81,7 +81,7 @@ float GeoNamesClient::getTimeOffset() {
JsonObject& root = json_buf.parseObject(jsonArray);
String offset = (const char*)root["dstOffset"];
if (!isDst) {
- offset = (const char*)root["rawOffset"];
+ offset = (const char*)root["gmtOffset"];
}
// Sample time: "2018-03-19 21:22"
datetime = (const char*)root["time"];
@@ -197,4 +197,4 @@ String GeoNamesClient::getDay00() {
-
+