diff --git a/index.html b/index.html index ec1f6e4..030f4fe 100644 --- a/index.html +++ b/index.html @@ -348,21 +348,20 @@ function isCamTime() { return h >= 19 || h < 8; } -// Double-buffer: load in hidden img, swap on load (no flicker) -const bufImg = new Image(); -bufImg.onload = () => { camImg.src = bufImg.src; }; - -function refreshCam() { +function updateCam() { if (isCamTime()) { camWrap.style.display = ''; - bufImg.src = '/api/cam/pulse-ox?' + Date.now(); + if (!camImg.src.includes('/stream')) { + camImg.src = '/api/cam/pulse-ox/stream'; + } } else { camWrap.style.display = 'none'; + camImg.src = ''; } } -refreshCam(); -setInterval(refreshCam, 1000); +updateCam(); +setInterval(updateCam, 60000);