Skip to content

Commit

Permalink
Add battery voltage display to status.html
Browse files Browse the repository at this point in the history
  • Loading branch information
melkati committed Apr 30, 2024
1 parent 8ff57f2 commit ca37314
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions data/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ <h1>Status Information</h1>
<div class="status-item" id="humidityItem">
<span class="status-label">Humidity:</span> <span id="humidity"></span>
</div>
<div class="status-item" id="batVoltageItem">
<span class="status-label">Battery Voltage:</span> <span id="batVoltage"></span>
</div>
<div class="status-item" id="wifiStatusItem">
<span class="status-label">WiFi Status:</span> <span id="wifiStatus"></span>
</div>
Expand Down Expand Up @@ -311,6 +314,28 @@ <h1>Status Information</h1>
.catch(error => console.error('Error fetching status:', error));
}

function getBatteryVoltage() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
console.log(this.responseText);
if (this.readyState == 4 && this.status == 200) {
document.getElementById("batVoltage").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "readBatteryVoltage", true);
xhttp.send();
}

setInterval(function () {
// Call a function repetatively with 1 Second interval
getBatteryVoltage();
}, 1000); // 1000mS update rate

window.onload = function () {
getBatteryVoltage();
};

// Set initial values when the page loads
document.addEventListener("DOMContentLoaded", loadStatusFromServer);
document.addEventListener("DOMContentLoaded", fetchVersion);
Expand Down
Binary file modified data/status.html.gz
Binary file not shown.

0 comments on commit ca37314

Please sign in to comment.