-
Notifications
You must be signed in to change notification settings - Fork 0
Add timecode sync, update readme #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bf4edd8
Add timecode sync, update readme
abhichothani42 3612094
add .js file
abhichothani42 46f70d3
Address pr comments
abhichothani42 347f1b8
Address pr comments
abhichothani42 582b068
add timecode page http serving script
lukeschmitt-tr 609acd5
remove unused files
abhichothani42 3ba7dc1
follow repo conventions
abhichothani42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,216 @@ | ||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="en-US"> | ||
| <head> | ||
|
|
||
|
|
||
| <meta charset="UTF-8"> | ||
|
|
||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <meta name="theme-color" content="#157878"> | ||
| <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> | ||
| <link rel="stylesheet" href="./style.css"> | ||
| <link rel="icon" href="data:,"> | ||
| </head> | ||
| <body> | ||
| <main id="content" class="main-content" role="main"> | ||
| <h1 id="precision-date-and-time-local">Precision Date and Time (Local)</h1> | ||
|
|
||
| <script src="./qrcodeborder.js"></script> | ||
|
|
||
| <style> | ||
| #qrcode{ | ||
| width: 100%; | ||
| } | ||
| div{ | ||
| width: 100%; | ||
| display: inline-block; | ||
| } | ||
| </style> | ||
|
|
||
| <p><strong>Refresh Rate</strong> <input type="range" id="fpsid" name="fpsid" min="10" max="120" value="30" style="width: 300px;" /><label for="fpsid"></label> <b id="fpstext"></b> FPS</p> | ||
|
|
||
| <p><strong>Timezone</strong> <input type="range" id="tzid" name="tzid" min="-48" max="56" value="0" style="width: 300px;" /><label for="tzid"></label> <b id="tztext"></b> hour <b id="tzmin"></b> minute<br /></p> | ||
|
|
||
| <p><strong>Daylight Saving Time</strong> <input type="checkbox" id="tdid" name="tdid" /> <label for="tdid">Active</label><br /></p> | ||
|
|
||
| <p><strong>QR Command Set Time</strong> <input type="checkbox" id="qrid" name="qrid" checked="true"/> <label for="qrid">Active</label><br /></p> | ||
|
|
||
| <p>Simply point your Labs enabled camera at this animated QR Code, to set your date and time very accurately to local time. This is particularly useful for multi-camera shoots, as it helps synchronize the timecode between cameras. As the camera’s internal clock will drift slowly over time, use this QR Code just before your multi-camera shoot for the best synchronization.</p> | ||
|
|
||
| <center> | ||
| <div id="qrcode"></div> | ||
| <br /> | ||
| </center> | ||
| <p>QR Command: <b id="qrtext"></b></p> | ||
|
|
||
| <p><strong>Compatibility:</strong> Labs enabled HERO5 Session, HERO7, HERO8, HERO9, HERO10, HERO11, HERO12, HERO13, MAX and BONES</p> | ||
|
|
||
| <script> | ||
| var once = true; | ||
| var qrcode; | ||
| var cmd = ""; | ||
| var id = 0; | ||
| var fps = 30; | ||
|
|
||
|
|
||
| function id5() { // 5 characters, so up to 17-bit ID | ||
| return ([1111]+1).replace(/1/g, c => | ||
| (c ^ crypto.getRandomValues(new Uint8Array(1))[0] % 10 >> c / 4).toString() | ||
| ); | ||
| } | ||
|
|
||
| function getMachineId() | ||
| { | ||
| let machineId = localStorage.getItem('MachineId'); | ||
| if (!machineId) { | ||
| //machineId = crypto.randomUUID(); | ||
| machineId = id5(); | ||
| localStorage.setItem('MachineId', machineId); | ||
| } | ||
| return machineId; | ||
| } | ||
|
|
||
| function isDST(d) { | ||
| let jan = new Date(d.getFullYear(), 0, 1).getTimezoneOffset(); | ||
| let jul = new Date(d.getFullYear(), 6, 1).getTimezoneOffset(); | ||
| return d.getTimezoneOffset() < Math.max(jan, jul); | ||
| } | ||
|
|
||
| function setTZ() { | ||
| var today = new Date(); | ||
| var tz,td = 0; | ||
| tz = today.getTimezoneOffset(); | ||
|
|
||
| if(isDST(today)) | ||
| td = 1; | ||
|
|
||
| if(document.getElementById("tzid") !== null) | ||
| { | ||
| document.getElementById("tzid").value = -tz/15; | ||
|
|
||
| var h = Math.trunc(tz/60); | ||
| var m = tz - h*60; | ||
| document.getElementById("tztext").innerHTML = -h; | ||
| document.getElementById("tzmin").innerHTML = -m; | ||
| } | ||
|
|
||
|
|
||
| if(document.getElementById("tdid") !== null) | ||
| { | ||
| if(td) { | ||
| document.getElementById("tdid").checked = true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function makeQR() { | ||
| if(once === true) | ||
| { | ||
| id = getMachineId(); // 5 character 10-base, so up to 17-bit ID | ||
| qrcode = new QRCode(document.getElementById("qrcode"), | ||
| { | ||
| text : "oT0", | ||
| width : 360, | ||
| height : 360, | ||
| correctLevel : QRCode.CorrectLevel.M | ||
| }); | ||
| once = false; | ||
| } | ||
| } | ||
| function padTime(i) { | ||
| if (i < 10) {i = "0" + i;} // add zero in front of numbers < 10 | ||
| return i; | ||
| } | ||
| function padTime1000(i) { | ||
| if (i >= 10 && i < 100) {i = "0" + i;} // add zero in front of numbers < 100 | ||
| else if (i < 10) {i = "00" + i;} // add zero in front of numbers < 10 | ||
| return i; | ||
| } | ||
| function timeLoop(prevTime) | ||
| { | ||
|
|
||
| if(document.getElementById("fpsid") !== null) | ||
| { | ||
| fps = parseInt(document.getElementById("fpsid").value); | ||
| document.getElementById("fpstext").innerHTML = fps; | ||
| } | ||
|
|
||
| var currTime = Date.now() | ||
| // exactly 60fps | ||
| if ((currTime - prevTime) < 1000./fps){ | ||
| requestAnimationFrame(function (){timeLoop(prevTime)}); | ||
|
abhichothani42 marked this conversation as resolved.
|
||
| return; | ||
| } | ||
|
|
||
| var today; | ||
| var yy,mm,dd,h,m,s; | ||
| var ms,tz; | ||
|
|
||
| today = new Date(); | ||
| yy = today.getFullYear() - 2000; | ||
| mm = today.getMonth() + 1; | ||
| dd = today.getDate(); | ||
| h = today.getHours(); | ||
| m = today.getMinutes(); | ||
| s = today.getSeconds(); | ||
| ms = today.getMilliseconds(); | ||
| yy = padTime(yy); | ||
| mm = padTime(mm); | ||
| dd = padTime(dd); | ||
| h = padTime(h); | ||
| m = padTime(m); | ||
| s = padTime(s); | ||
| //ms = Math.floor(ms / 10); // hundredths | ||
| ms = padTime1000(ms); | ||
|
|
||
| if(document.getElementById("tzid") !== null) | ||
| { | ||
| tz = parseInt(document.getElementById("tzid").value) * 15; | ||
|
|
||
| var H = Math.trunc(tz/60); | ||
| var M = tz - H*60; | ||
| document.getElementById("tztext").innerHTML = H; | ||
| document.getElementById("tzmin").innerHTML = M; | ||
|
|
||
| if(Math.trunc(tz/60) == tz/60) | ||
| tz = tz/60; // only need hours when precise. | ||
| } | ||
|
|
||
| var td = 0; | ||
| if(document.getElementById("tdid") !== null) | ||
| { | ||
| if(document.getElementById("tdid").checked) { | ||
| td = 1; | ||
| } | ||
| } | ||
|
|
||
| var set_time = true; | ||
| if(document.getElementById("qrid") !== null) | ||
| { | ||
| set_time = document.getElementById("qrid").checked; | ||
| } | ||
| cmd = "#" + yy + mm + dd + h + m + s + "." + ms; | ||
| if(set_time){ | ||
| cmd = "oT" + yy + mm + dd + h + m + s + "." + ms + "oTD" + td + "oTZ" + tz + "oTI" + id; | ||
| } | ||
| qrcode.clear(); | ||
| qrcode.makeCode(cmd); | ||
| document.getElementById("qrtext").innerHTML = cmd; | ||
|
|
||
| requestAnimationFrame(function (){timeLoop(currTime)}); | ||
| } | ||
|
|
||
| function myReloadFunction() { | ||
| location.reload(); | ||
| } | ||
|
|
||
| makeQR(); | ||
| setTZ(); | ||
| timeLoop(Date.now()); | ||
|
|
||
| </script> | ||
|
|
||
| </main> | ||
| </body> | ||
| </html> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.