Skip to content

Commit 7451520

Browse files
committed
calibrate: Better autorefresh (backported from folk2)
1 parent 680a429 commit 7451520

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

virtual-programs/calibrate/calibrate.folk

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -487,22 +487,26 @@ Wish the web server handles route "/calibrate$" with handler [list apply {{UNIT_
487487
});
488488

489489
function advanceCamera() {
490-
cameraFrame.src = cameraFrame.src + '0'
490+
cameraFrame.src = '/camera-frame?' + Math.random()
491491
}
492492
</script>
493493

494494
<p>Use this camera preview to debug why printed and/or projected tags aren't being recognized (maybe overexposure, maybe your camera isn't in a good position): <button id="refreshButton" onclick="advanceCamera()">Refresh Preview</button> <input type="checkbox" value="true" id="auto-refresh-checkbox" checked>
495-
<label for="auto-refresh-checkbox">Automatically refresh preview (May not work well during calibration)</label> </p><br> <img src="/camera-frame?0" id="cameraFrame" style="max-width: 100%">
495+
<label for="auto-refresh-checkbox">Automatically refresh preview</label> </p><br> <img src="/camera-frame" id="cameraFrame" style="max-width: 100%">
496496

497497
<script>
498498
const refreshButton = document.getElementById('refreshButton');
499499
const autoRefreshCheckbox = document.getElementById('auto-refresh-checkbox');
500-
setInterval(() => {
501-
if (autoRefreshCheckbox.checked) {
502-
refreshButton.click()
503-
}
504-
console.log("checked?", autoRefreshCheckbox.checked)
505-
}, 100)
500+
cameraFrame.addEventListener('load', () => {
501+
if (autoRefreshCheckbox.checked) {
502+
advanceCamera();
503+
}
504+
});
505+
autoRefreshCheckbox.addEventListener('change', () => {
506+
if (autoRefreshCheckbox.checked) {
507+
advanceCamera();
508+
}
509+
});
506510
</script>
507511

508512

0 commit comments

Comments
 (0)