firmware wip - add time in menu, make ntp offset work
This commit is contained in:
parent
3753dfcd96
commit
3c8cba0b45
1 changed files with 24 additions and 9 deletions
|
@ -286,6 +286,7 @@ const char HTMLheader[] PROGMEM = R"EOF(
|
||||||
<li><a href="/wifiSettings">WiFi settings</a></li>
|
<li><a href="/wifiSettings">WiFi settings</a></li>
|
||||||
<li><a href="/help">Help</a></li>
|
<li><a href="/help">Help</a></li>
|
||||||
<li><span id="MenuGrowName"></span></li>
|
<li><span id="MenuGrowName"></span></li>
|
||||||
|
<li><span id="MenuTime"></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="center">
|
<div class="center">
|
||||||
|
|
||||||
|
@ -833,6 +834,7 @@ void wifiConnect() {
|
||||||
|
|
||||||
Serial.println(":: Getting time from NTP ::");
|
Serial.println(":: Getting time from NTP ::");
|
||||||
timeClient.begin();
|
timeClient.begin();
|
||||||
|
timeClient.setTimeOffset(ntpOffset * 60 * 60);
|
||||||
timeClient.update();
|
timeClient.update();
|
||||||
while ( ! timeClient.isTimeSet()) {
|
while ( ! timeClient.isTimeSet()) {
|
||||||
timeClient.update();
|
timeClient.update();
|
||||||
|
@ -1073,7 +1075,8 @@ void WebHandler() {
|
||||||
|
|
||||||
void WebRestart() {
|
void WebRestart() {
|
||||||
String body = FPSTR(HTMLheader);
|
String body = FPSTR(HTMLheader);
|
||||||
if(NeedRestart == true) {
|
// TODO only debug and development solution, remove this later
|
||||||
|
if(true) {
|
||||||
body += "<h1>Restarting</h1>";
|
body += "<h1>Restarting</h1>";
|
||||||
body += "<div class='infomsg'>After restart CanGrow will be connected to WiFi SSID<br><b>";
|
body += "<div class='infomsg'>After restart CanGrow will be connected to WiFi SSID<br><b>";
|
||||||
body += WIFIssid;
|
body += WIFIssid;
|
||||||
|
@ -1123,19 +1126,28 @@ void WebAuthApi() {
|
||||||
// returns footer with javascript stuff
|
// returns footer with javascript stuff
|
||||||
String returnHTMLfooter() {
|
String returnHTMLfooter() {
|
||||||
String footer;
|
String footer;
|
||||||
// show the GrowName in the menu if set
|
|
||||||
if(strlen(GrowName) > 0){
|
|
||||||
|
|
||||||
// add replaceStr javascript function from PROGMEM
|
// add replaceStr javascript function from PROGMEM
|
||||||
// first is dst ID, second is content (&#.. is a seedling emoji )
|
// first is dst ID, second is content (&#.. is a seedling emoji )
|
||||||
footer += FPSTR(JSreplaceStr);
|
footer += FPSTR(JSreplaceStr);
|
||||||
|
// print actual time in header
|
||||||
|
footer += "<script>replaceStr('MenuTime', '";
|
||||||
|
footer += timeClient.getFormattedTime();
|
||||||
|
footer += "');\n";
|
||||||
|
footer += "</script>";
|
||||||
|
|
||||||
|
// show the GrowName in the menu if set
|
||||||
|
if(strlen(GrowName) > 0){
|
||||||
|
|
||||||
|
|
||||||
footer += "<script>replaceStr('MenuGrowName', '🌱 ";
|
footer += "<script>replaceStr('MenuGrowName', '🌱 ";
|
||||||
footer += GrowName;
|
footer += GrowName;
|
||||||
footer += "');\n";
|
footer += "');\n";
|
||||||
// include the GrowName in the title
|
// include the GrowName in the title
|
||||||
footer += "document.title = 'CanGrow - ";
|
footer += "document.title = 'CanGrow - ";
|
||||||
footer += GrowName;
|
footer += GrowName;
|
||||||
footer += "';</script>";
|
footer += "';";
|
||||||
|
footer += "</script>";
|
||||||
}
|
}
|
||||||
|
|
||||||
footer += FPSTR(HTMLfooter);
|
footer += FPSTR(HTMLfooter);
|
||||||
|
@ -1245,7 +1257,6 @@ void WEBroot() {
|
||||||
body += "<h1>🌱 ";
|
body += "<h1>🌱 ";
|
||||||
body += GrowName;
|
body += GrowName;
|
||||||
body += "</h1>";
|
body += "</h1>";
|
||||||
body += "<p>";
|
|
||||||
body += "Grow started: ";
|
body += "Grow started: ";
|
||||||
body += returnStrDateFromEpoch(GrowStart);
|
body += returnStrDateFromEpoch(GrowStart);
|
||||||
body += "<br>";
|
body += "<br>";
|
||||||
|
@ -1295,7 +1306,7 @@ void WEBroot() {
|
||||||
body += "</form>";
|
body += "</form>";
|
||||||
|
|
||||||
|
|
||||||
body += "</p>";
|
|
||||||
|
|
||||||
|
|
||||||
body += returnHTMLfooter();
|
body += returnHTMLfooter();
|
||||||
|
@ -1431,7 +1442,7 @@ void WEBsystemSettings() {
|
||||||
body += "</select><br>\n";
|
body += "</select><br>\n";
|
||||||
|
|
||||||
// ntpOffset int
|
// ntpOffset int
|
||||||
body += "NTP offset: <input type='number' name='ntpOffset' min='0' value='";
|
body += "NTP offset: <input type='number' name='ntpOffset' min='-12' max='14' value='";
|
||||||
body += ntpOffset;
|
body += ntpOffset;
|
||||||
body+= "' required><br>\n";
|
body+= "' required><br>\n";
|
||||||
|
|
||||||
|
@ -1642,6 +1653,10 @@ void POSTsystemSettings() {
|
||||||
|
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
|
|
||||||
|
// update time with new offset
|
||||||
|
timeClient.setTimeOffset(ntpOffset * 60 * 60);
|
||||||
|
timeClient.update();
|
||||||
|
|
||||||
Serial.println(":: POSTsystemSettings ::");
|
Serial.println(":: POSTsystemSettings ::");
|
||||||
|
|
||||||
Serial.print("configured: ");
|
Serial.print("configured: ");
|
||||||
|
|
Loading…
Reference in a new issue