Status checking for mobile

This commit is contained in:
2025-02-24 13:57:43 +00:00
parent 798a708b5a
commit 82634889b8

View File

@@ -122,13 +122,6 @@ line-height:140%;
}) })
} }
function updateStatus() {
if (avgWindValid == 1 && windValid == 1) {
document.getElementById("status").style.backgroundColor = '#00AA00';
document.getElementById("status").innerHTML = "OK";
}
}
function updateWind() { function updateWind() {
document.getElementById("windSpeed").innerHTML = zeroFilledDir + "/" + instantWindSpeed; document.getElementById("windSpeed").innerHTML = zeroFilledDir + "/" + instantWindSpeed;
} }
@@ -137,6 +130,7 @@ line-height:140%;
updateWindDirection(avgWindDir); updateWindDirection(avgWindDir);
document.getElementById("avgWindSpeed").innerHTML = avgWindDir + "/" + avgWindSpeed; document.getElementById("avgWindSpeed").innerHTML = avgWindDir + "/" + avgWindSpeed;
document.getElementById("avgWindGust").innerHTML = avgWindGustDir + "/" + avgWindGustSpeed; document.getElementById("avgWindGust").innerHTML = avgWindGustDir + "/" + avgWindGustSpeed;
windAvgValid = 1;
} }
function invalidateDisplay() { function invalidateDisplay() {
@@ -318,6 +312,34 @@ line-height:140%;
function updateWindDirection(degrees) { function updateWindDirection(degrees) {
windDirection = degrees % 360; windDirection = degrees % 360;
drawCompass(); drawCompass();
}
function statusLoop() {
var dt = new Date();
secs = (dt.getTime() - lastWind)/1000;
if (secs > 10 && windValid == 1) {
invalidateWind();
console.log("Invalidating instant wind due to late message")
document.getElementById("status").innerHTML = "Missing Wind message";
document.getElementById("status").style.backgroundColor = '#AA0000';
}
secs = (dt.getTime() - lastAvgWind)/1000;
if (secs > 150 && windAvgValid == 1) {
invalidateAvgWind();
console.log("Invalidating average wind due to late message")
document.getElementById("status").innerHTML = "Missing avg Wind message";
document.getElementById("status").style.backgroundColor = '#AA0000';
}
if (avgWindValid == 1 && windValid == 1) {
document.getElementById("status").style.backgroundColor = '#00AA00';
document.getElementById("status").innerHTML = "OK";
}
} }
</script> </script>
@@ -377,9 +399,10 @@ invalidateDisplay();
MQTTconnect(); MQTTconnect();
getPressure(); getPressure();
getInitialArchive(); getInitialArchive();
drawCompass(); drawCompass();
setInterval(statusLoop, 5000);
setInterval(getPressure, 600000);
</script> </script>
</body> </body>