mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 11:55:00 +00:00
update image refresh logic to be more optimized
This commit is contained in:
@@ -43,19 +43,21 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
const dataElement = document.createElement("p");
|
||||
dataElement.textContent = `${key}: ${value}`;
|
||||
sensorDataContainer.appendChild(dataElement); // Voeg het element toe aan de container
|
||||
sensorDataContainer.appendChild(dataElement); // Add the element to the container
|
||||
}
|
||||
}
|
||||
|
||||
// Update the image
|
||||
function updateImage() {
|
||||
var img = document.getElementById("robot-image");
|
||||
async function updateImage() {
|
||||
let img = document.getElementById("robot-image");
|
||||
img.src = "/image?" + new Date().getTime(); // Add timestamp to avoid caching
|
||||
// Wait for 200 milliseconds before fetching the next image
|
||||
setTimeout(updateImage, 200);
|
||||
}
|
||||
|
||||
// Fetch and display sensor data every 1 second
|
||||
setInterval(parseData, 1000);
|
||||
|
||||
// Update the image every 200 milliseconds
|
||||
setInterval(updateImage, 100);
|
||||
// Start updating the image
|
||||
updateImage();
|
||||
});
|
Reference in New Issue
Block a user