diff --git a/data/logic.js b/data/logic.js index e774409..4d554b4 100644 --- a/data/logic.js +++ b/data/logic.js @@ -7,7 +7,7 @@ window.addEventListener('DOMContentLoaded', (event) => { fetch(apiUrl) .then(response => response.json()) .then(data => { - document.getElementById('voltage').textContent = roundToTwo(data.voltage)+ ' V' || 'N/A'; + document.getElementById('voltage').textContent = roundToTwo(data.bus_voltage)+ ' V' || 'N/A'; document.getElementById('current').textContent = roundToTwo(data.current)+ ' mA' || 'N/A'; }) .catch(error => { @@ -19,6 +19,49 @@ window.addEventListener('DOMContentLoaded', (event) => { setInterval(fetchData, 5000); // fetch every 5 seconds }); +window.addEventListener('DOMContentLoaded', (event) => { + // URL of your API + const apiUrl = '/telemetry'; + + function fetchData() { + // Fetching data from the API + fetch(apiUrl) + .then(response => response.json()) + .then(data => { + document.getElementById('uptime').textContent = roundToTwo(data.uptime_seconds)+ ' s' || 'N/A'; + document.getElementById('heap').textContent = roundToTwo(data.heap_percent)+ ' %' || 'N/A'; + }) + .catch(error => { + console.error("There was an error fetching data from the API", error); + }); + } + + fetchData(); // fetch immediately on page load + setInterval(fetchData, 5000); // fetch every 5 seconds +}); + +window.addEventListener('DOMContentLoaded', (event) => { + // URL of your API + const apiUrl = '/water_data'; + + function fetchData() { + // Fetching data from the API + fetch(apiUrl) + .then(response => response.json()) + .then(data => { + document.getElementById('level').textContent = roundToTwo(data.water_height)+ ' cm' || 'N/A'; + document.getElementById('liters').textContent = roundToTwo(data.liters)+ ' l' || 'N/A'; + document.getElementById('percentage').textContent = roundToTwo(data.percentage)+ ' %' || 'N/A'; + }) + .catch(error => { + console.error("There was an error fetching data from the API", error); + }); + } + + fetchData(); // fetch immediately on page load + setInterval(fetchData, 5000); // fetch every 5 seconds +}); + window.addEventListener('DOMContentLoaded', (event) => { const apiUrl = '/network_info'; diff --git a/data/settings.html b/data/settings.html index 6bc8904..89d0377 100644 --- a/data/settings.html +++ b/data/settings.html @@ -20,39 +20,39 @@ - -
+