v2
added auto reload of status infos
This commit is contained in:
parent
af4fa9cbcf
commit
3c7d2f41b5
@ -598,10 +598,10 @@ void handleRoot() {
|
|||||||
html += "<b>Zeitzone:</b> Europe/Berlin (CET/CEST)<br>";
|
html += "<b>Zeitzone:</b> Europe/Berlin (CET/CEST)<br>";
|
||||||
html += "<b>WLAN:</b> " + String(WiFi.status() == WL_CONNECTED ? "Verbunden" : "Getrennt") + "<br>";
|
html += "<b>WLAN:</b> " + String(WiFi.status() == WL_CONNECTED ? "Verbunden" : "Getrennt") + "<br>";
|
||||||
html += "<b>Analogwert:</b> <span id='analogVal'>--</span><br>";
|
html += "<b>Analogwert:</b> <span id='analogVal'>--</span><br>";
|
||||||
html += "<b>Auto-Sync Zeit:</b> " + String(autoSyncMinute) + ":" + String(autoSyncSecond) + "<br>";
|
html += "<b>Auto-Sync Zeit:</b> <span id='autoSyncTime'>" + String(autoSyncMinute) + ":" + (autoSyncSecond < 10 ? "0" : "") + String(autoSyncSecond) + "</span><br>";
|
||||||
html += "<b>Sensor-Triggerwert:</b> " + String(sensorTriggerValue) + " (" + String(sensorTriggerAbove ? "über" : "unter") + ")<br>";
|
html += "<b>Sensor-Triggerwert:</b> <span id='sensorTrigger'>" + String(sensorTriggerValue) + " (" + String(sensorTriggerAbove ? "über" : "unter") + ")</span><br>";
|
||||||
html += "<b>OTA (IDE):</b> aktiv • <b>OTA (Web):</b> <a href='/update'>/update</a><br>";
|
html += "<b>OTA (IDE):</b> aktiv • <b>OTA (Web):</b> <a href='/update'>/update</a><br>";
|
||||||
html += "<b>Steps/Rev:</b> " + String(stepsPerRev) + "</div>";
|
html += "<b>Steps/Rev:</b> <span id='stepsPerRev'>" + String(stepsPerRev) + "</span></div>";
|
||||||
|
|
||||||
html += "<div class='card'><h3>System-Log</h3>";
|
html += "<div class='card'><h3>System-Log</h3>";
|
||||||
html += "<pre id='logBox' style='max-height:200px;overflow-y:auto;background:#1e1e2f;padding:8px;border-radius:6px;margin:0'>";
|
html += "<pre id='logBox' style='max-height:200px;overflow-y:auto;background:#1e1e2f;padding:8px;border-radius:6px;margin:0'>";
|
||||||
@ -687,7 +687,7 @@ void handleRoot() {
|
|||||||
"setTimeout(()=>{"
|
"setTimeout(()=>{"
|
||||||
"fetch(path,{method:'POST',body:new URLSearchParams(formData)})"
|
"fetch(path,{method:'POST',body:new URLSearchParams(formData)})"
|
||||||
".then(r=>r.text())"
|
".then(r=>r.text())"
|
||||||
".then(t=>{showInfo(t);updateAnalog();updateLog();updateTime();})"
|
".then(t=>{showInfo(t);updateAnalog();updateLog();updateTime();updateStatus();})"
|
||||||
".catch(e=>showInfo('Fehler: '+e));"
|
".catch(e=>showInfo('Fehler: '+e));"
|
||||||
"},100);"
|
"},100);"
|
||||||
"return true;"
|
"return true;"
|
||||||
@ -702,6 +702,13 @@ void handleRoot() {
|
|||||||
"try{const r=await fetch('/time');document.getElementById('curTime').innerText=await r.text();}catch(e){}"
|
"try{const r=await fetch('/time');document.getElementById('curTime').innerText=await r.text();}catch(e){}"
|
||||||
"try{const r2=await fetch('/ntptime');document.getElementById('ntpTime').innerText=await r2.text();}catch(e){}"
|
"try{const r2=await fetch('/ntptime');document.getElementById('ntpTime').innerText=await r2.text();}catch(e){}"
|
||||||
"}"
|
"}"
|
||||||
|
"async function updateStatus(){"
|
||||||
|
"try{"
|
||||||
|
"const r1=await fetch('/status/autosync');document.getElementById('autoSyncTime').innerText=await r1.text();"
|
||||||
|
"const r2=await fetch('/status/trigger');document.getElementById('sensorTrigger').innerText=await r2.text();"
|
||||||
|
"const r3=await fetch('/status/stepsperrev');document.getElementById('stepsPerRev').innerText=await r3.text();"
|
||||||
|
"}catch(e){}"
|
||||||
|
"}"
|
||||||
"setInterval(updateAnalog,1000);"
|
"setInterval(updateAnalog,1000);"
|
||||||
"setInterval(updateLog,2000);"
|
"setInterval(updateLog,2000);"
|
||||||
"setInterval(updateTime,1000);"
|
"setInterval(updateTime,1000);"
|
||||||
@ -977,6 +984,21 @@ void handleDebugTime() {
|
|||||||
server.send(200, "text/plain", out);
|
server.send(200, "text/plain", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleStatusAutoSync() {
|
||||||
|
char buf[10];
|
||||||
|
snprintf(buf, sizeof(buf), "%d:%02d", autoSyncMinute, autoSyncSecond);
|
||||||
|
server.send(200, "text/plain", String(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleStatusTrigger() {
|
||||||
|
String msg = String(sensorTriggerValue) + " (" + String(sensorTriggerAbove ? "über" : "unter") + ")";
|
||||||
|
server.send(200, "text/plain", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleStatusStepsPerRev() {
|
||||||
|
server.send(200, "text/plain", String(stepsPerRev));
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------- NTP -------------------
|
// ------------------- NTP -------------------
|
||||||
void syncTimeFromNTP() {
|
void syncTimeFromNTP() {
|
||||||
if (WiFi.status() != WL_CONNECTED) {
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
@ -1063,6 +1085,9 @@ void setup() {
|
|||||||
server.on("/setautosync", HTTP_POST, handleSetAutoSync);
|
server.on("/setautosync", HTTP_POST, handleSetAutoSync);
|
||||||
server.on("/ntptime", HTTP_GET, handleNtpTime);
|
server.on("/ntptime", HTTP_GET, handleNtpTime);
|
||||||
server.on("/debugtime", HTTP_GET, handleDebugTime);
|
server.on("/debugtime", HTTP_GET, handleDebugTime);
|
||||||
|
server.on("/status/autosync", HTTP_GET, handleStatusAutoSync);
|
||||||
|
server.on("/status/trigger", HTTP_GET, handleStatusTrigger);
|
||||||
|
server.on("/status/stepsperrev", HTTP_GET, handleStatusStepsPerRev);
|
||||||
|
|
||||||
server.begin();
|
server.begin();
|
||||||
addLog("Webserver gestartet");
|
addLog("Webserver gestartet");
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user