2017-11-22 16:58:02 +00:00
|
|
|
'use strict';
|
|
|
|
const BOLEX = {
|
|
|
|
angle : 133,
|
|
|
|
prism : 0.8,
|
2018-02-02 20:36:28 +00:00
|
|
|
iso : 100,
|
|
|
|
fstop : 5.6,
|
2017-11-22 16:58:02 +00:00
|
|
|
expected : 630
|
|
|
|
};
|
|
|
|
const STATE = {
|
|
|
|
dir : true,
|
|
|
|
exposure : 630, //always ms
|
|
|
|
delay : 0,
|
|
|
|
scale : 'ms',
|
|
|
|
delayScale : 'ms',
|
2017-12-21 04:47:37 +00:00
|
|
|
counter : 0,
|
|
|
|
sequence : false
|
2017-11-22 17:45:52 +00:00
|
|
|
};
|
2017-12-13 22:52:25 +00:00
|
|
|
|
2017-11-22 16:58:02 +00:00
|
|
|
//functions
|
2017-11-22 17:45:52 +00:00
|
|
|
window.frame = null;
|
|
|
|
window.getState = null;
|
|
|
|
window.setDir = null;
|
|
|
|
window.setExposure = null;
|
|
|
|
window.setDelay = null;
|
|
|
|
window.setCounter = null;
|
2017-12-21 04:49:51 +00:00
|
|
|
window.sequence = null;
|
2018-02-12 18:58:00 +00:00
|
|
|
window.reset = null;
|
|
|
|
window.restart = null;
|
|
|
|
window.update = null;
|
2017-11-22 17:45:52 +00:00
|
|
|
|
2017-11-22 16:58:02 +00:00
|
|
|
//ms
|
|
|
|
var shutter = function (exposure) {
|
|
|
|
let fraction = BOLEX.expected / 1000;
|
|
|
|
let speed;
|
|
|
|
let corrected;
|
|
|
|
let str;
|
|
|
|
if (exposure > BOLEX.expected) {
|
|
|
|
//if exposure is explicitly set
|
|
|
|
fraction = exposure / 1000;
|
|
|
|
speed = fraction;
|
|
|
|
} else {
|
|
|
|
speed = fraction * (BOLEX.angle / 360);
|
|
|
|
}
|
|
|
|
corrected = speed * BOLEX.prism;
|
|
|
|
if (corrected < 1.0) {
|
|
|
|
//less than a second
|
|
|
|
str = '1/' + Math.round(Math.pow(corrected, -1)) + ' sec';
|
|
|
|
} else if (corrected >= 1.0 && corrected < 60) {
|
|
|
|
//greater than a second, less than a minute
|
|
|
|
str = '' + (Math.round(corrected * 10) / 10) + ' sec'
|
|
|
|
} else if (corrected >= 60 && corrected < 60 * 60) {
|
|
|
|
//greater than a minute, less than an hour
|
|
|
|
str = '' + (Math.round(corrected / 6) / 10) + ' min';
|
|
|
|
} else if (corrected >= 60 * 60 && corrected < 60 * 60 * 24) {
|
|
|
|
//greater than an hour, less than a day
|
|
|
|
str = '' + (Math.round(corrected / (6 * 60)) / 10) + ' hr';
|
|
|
|
} else if (corrected >= 60 * 60 * 24) {
|
|
|
|
//greater than a day
|
|
|
|
str = '' + (Math.round(corrected / (6 * 60 * 24)) / 10) + ' day';
|
|
|
|
}
|
|
|
|
return { speed : speed, str : str }
|
|
|
|
};
|
|
|
|
|
|
|
|
var scaleAuto = function (ms) {
|
|
|
|
if (ms < 1000) {
|
|
|
|
return 'ms'
|
|
|
|
} else if (ms >= 1000 && ms < 1000 * 60) {
|
|
|
|
return 'sec'
|
|
|
|
} else if (ms >= 1000 * 60 && ms < 1000 * 60 * 60) {
|
|
|
|
return 'min'
|
|
|
|
} else if (ms >= 1000 * 60 * 60) {
|
|
|
|
return 'hour'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var scaleTime = function (raw, scale) {
|
|
|
|
if (scale === 'ms') {
|
|
|
|
return raw
|
|
|
|
} else if (scale === 'sec') {
|
|
|
|
return raw * 1000;
|
|
|
|
} else if (scale === 'min') {
|
|
|
|
return raw * (1000 * 60);
|
|
|
|
} else if (scale === 'hour') {
|
|
|
|
return raw * (1000 * 60 * 60);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var setExposureScale = function () {
|
|
|
|
const scale = document.getElementById('scale').value;
|
|
|
|
const elem = document.getElementById('exposure');
|
|
|
|
if (scale === 'ms') {
|
|
|
|
elem.value = STATE.exposure;
|
|
|
|
} else if (scale === 'sec') {
|
|
|
|
elem.value = STATE.exposure / 1000;
|
|
|
|
} else if (scale === 'min') {
|
|
|
|
elem.value = STATE.exposure / (1000 * 60);
|
|
|
|
} else if (scale === 'hour') {
|
|
|
|
elem.value = STATE.exposure / (1000 * 60 * 60);
|
|
|
|
}
|
|
|
|
STATE.scale = scale;
|
|
|
|
};
|
|
|
|
|
|
|
|
var setDelayScale = function () {
|
2017-12-13 22:52:25 +00:00
|
|
|
const scale = document.getElementById('delayScale').value;
|
2017-11-22 16:58:02 +00:00
|
|
|
const elem = document.getElementById('delay');
|
|
|
|
if (scale === 'ms') {
|
|
|
|
elem.value = STATE.delay;
|
|
|
|
} else if (scale === 'sec') {
|
|
|
|
elem.value = STATE.delay / 1000;
|
|
|
|
} else if (scale === 'min') {
|
|
|
|
elem.value = STATE.delay / (1000 * 60);
|
|
|
|
} else if (scale === 'hour') {
|
|
|
|
elem.value = STATE.delay / (1000 * 60 * 60);
|
|
|
|
}
|
|
|
|
STATE.delayScale = scale;
|
|
|
|
};
|
|
|
|
|
|
|
|
var setDirLabel = function (dir) {
|
|
|
|
const bwdLabel = document.getElementById('bwdLabel');
|
|
|
|
const fwdLabel = document.getElementById('fwdLabel');
|
2017-12-24 03:30:17 +00:00
|
|
|
const but = document.getElementById('frame');
|
2017-11-22 16:58:02 +00:00
|
|
|
if (dir) {
|
2017-12-24 03:30:17 +00:00
|
|
|
bwdLabel.classList.remove('selected');
|
|
|
|
fwdLabel.classList.add('selected');
|
2017-12-30 03:42:49 +00:00
|
|
|
but.innerHTML = '+1 FRAME';
|
2017-11-22 16:58:02 +00:00
|
|
|
} else {
|
2017-12-24 03:30:17 +00:00
|
|
|
fwdLabel.classList.remove('selected');
|
|
|
|
bwdLabel.classList.add('selected');
|
2017-12-30 03:42:49 +00:00
|
|
|
but.innerHTML = '-1 FRAME';
|
2017-11-22 16:58:02 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
var incCounter = function (val) {
|
|
|
|
const elem = document.getElementById('counter');
|
|
|
|
const current = elem.value;
|
|
|
|
elem.value = (parseInt(current) + val);
|
|
|
|
STATE.counter += val;
|
|
|
|
};
|
|
|
|
var forceCounter = function (val) {
|
|
|
|
document.getElementById('counter').value = val;
|
|
|
|
}
|
|
|
|
var unsetPages = function () {
|
2017-11-23 00:48:45 +00:00
|
|
|
const pages = document.querySelectorAll('.page');
|
|
|
|
const icons = document.querySelectorAll('.icon');
|
2017-11-22 16:58:02 +00:00
|
|
|
for (let icon of icons) {
|
|
|
|
if (icon.classList.contains('selected')) icon.classList.remove('selected');
|
2017-11-23 00:48:45 +00:00
|
|
|
};
|
2017-11-22 16:58:02 +00:00
|
|
|
for (let page of pages){;
|
|
|
|
if (page.classList.contains('selected')) page.classList.remove('selected');
|
|
|
|
}
|
2017-11-23 00:48:45 +00:00
|
|
|
|
2017-11-22 16:58:02 +00:00
|
|
|
};
|
2017-12-13 22:52:25 +00:00
|
|
|
|
|
|
|
var setState = function (res) {
|
|
|
|
let exposure;
|
|
|
|
let exposureScale;
|
|
|
|
let delayScale;
|
|
|
|
|
|
|
|
if (res.frame.dir !== true) {
|
|
|
|
document.getElementById('dir').checked = true;
|
|
|
|
STATE.dir = res.frame.dir;
|
|
|
|
setDirLabel(false);
|
2017-12-30 03:05:00 +00:00
|
|
|
} else {
|
|
|
|
STATE.dir = res.frame.dir;
|
|
|
|
setDirLabel(true);
|
2017-12-13 22:52:25 +00:00
|
|
|
}
|
|
|
|
document.getElementById('counter').value = res.counter;
|
|
|
|
STATE.counter = res.counter;
|
|
|
|
//Exposure
|
|
|
|
if (res.frame.exposure === 0) {
|
|
|
|
res.frame.exposure = BOLEX.expected;
|
|
|
|
}
|
|
|
|
STATE.exposure = res.frame.exposure;
|
|
|
|
exposure = shutter(STATE.exposure);
|
|
|
|
exposureScale = scaleAuto(STATE.exposure);
|
|
|
|
|
2017-12-24 03:30:17 +00:00
|
|
|
document.getElementById('str').innerHTML = exposure.str;
|
2017-12-13 22:52:25 +00:00
|
|
|
document.getElementById('scale').value = exposureScale;
|
|
|
|
setExposureScale();
|
|
|
|
|
|
|
|
STATE.delay = res.frame.delay;
|
|
|
|
delayScale = scaleAuto(STATE.delay);
|
|
|
|
document.getElementById('delayScale').value = delayScale;
|
|
|
|
setDelayScale();
|
2017-12-21 05:03:32 +00:00
|
|
|
|
|
|
|
if (res.sequence == true) {
|
|
|
|
STATE.sequence = true;
|
2017-12-24 03:22:36 +00:00
|
|
|
if (mobile.ble) mobile.ble.active = true;
|
2017-12-22 20:28:09 +00:00
|
|
|
seqState(true);
|
2018-01-02 05:35:20 +00:00
|
|
|
} else {
|
|
|
|
seqState(false);
|
2017-12-21 05:03:32 +00:00
|
|
|
}
|
2017-12-13 22:52:25 +00:00
|
|
|
};
|
2017-12-22 20:28:09 +00:00
|
|
|
|
|
|
|
var seqState = function (state) {
|
|
|
|
const elem = document.getElementById('seq')
|
|
|
|
if (state) {
|
|
|
|
if (!elem.classList.contains('focus')) {
|
|
|
|
elem.classList.add('focus');
|
2017-12-22 21:34:06 +00:00
|
|
|
elem.innerHTML = 'STOP SEQUENCE';
|
2017-12-22 20:28:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (elem.classList.contains('focus')) {
|
|
|
|
elem.classList.remove('focus');
|
2017-12-22 21:34:06 +00:00
|
|
|
elem.innerHTML = 'START SEQUENCE';
|
2017-12-22 20:28:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-11-22 16:58:02 +00:00
|
|
|
var appPage = function () {
|
|
|
|
unsetPages();
|
|
|
|
document.getElementById('app').classList.add('selected');
|
|
|
|
document.getElementById('appIcon').classList.add('selected');
|
|
|
|
};
|
|
|
|
var settingsPage = function () {
|
|
|
|
unsetPages();
|
|
|
|
document.getElementById('settings').classList.add('selected');
|
|
|
|
document.getElementById('settingsIcon').classList.add('selected');
|
|
|
|
};
|
|
|
|
var mscriptPage = function () {
|
|
|
|
unsetPages();
|
|
|
|
document.getElementById('mscript').classList.add('selected');
|
|
|
|
document.getElementById('mscriptIcon').classList.add('selected');
|
2017-11-23 00:48:45 +00:00
|
|
|
editor.cm.refresh();
|
2017-11-22 16:58:02 +00:00
|
|
|
};
|
2018-01-09 05:06:17 +00:00
|
|
|
var cameraPage = function () {
|
|
|
|
unsetPages();
|
|
|
|
document.getElementById('camera').classList.add('selected');
|
|
|
|
document.getElementById('cameraIcon').classList.add('selected');
|
|
|
|
};
|
2018-02-12 18:58:00 +00:00
|
|
|
|
|
|
|
var isNumeric = function (n) {
|
|
|
|
return !isNaN(parseFloat(n)) && isFinite(n);
|
2017-12-13 22:52:25 +00:00
|
|
|
};
|
2018-02-12 18:58:00 +00:00
|
|
|
|
|
|
|
var UI = {};
|
|
|
|
|
|
|
|
UI.overlay = {
|
|
|
|
elem : document.getElementById('overlay')
|
|
|
|
}
|
|
|
|
UI.overlay.show = function () {
|
|
|
|
if (!UI.overlay.elem.classList.contains('active')) {
|
|
|
|
UI.overlay.elem.classList.add('active');
|
2017-12-13 22:52:25 +00:00
|
|
|
}
|
|
|
|
};
|
2018-02-12 18:58:00 +00:00
|
|
|
UI.overlay.hide = function () {
|
|
|
|
if (UI.overlay.elem.classList.contains('active')) {
|
|
|
|
UI.overlay.elem.classList.remove('active');
|
2017-12-13 22:52:25 +00:00
|
|
|
}
|
2018-02-03 21:50:14 +00:00
|
|
|
};
|
2018-02-12 18:58:00 +00:00
|
|
|
UI.spinner = {
|
|
|
|
elem : document.getElementById('spinner')
|
|
|
|
}
|
|
|
|
UI.spinner.opts = {
|
|
|
|
lines: 13 // The number of lines to draw
|
|
|
|
, length: 33 // The length of each line
|
|
|
|
, width: 11 // The line thickness
|
|
|
|
, radius: 30 // The radius of the inner circle
|
|
|
|
, scale: 0.5 // Scales overall size of the spinner
|
|
|
|
, corners: 1 // Corner roundness (0..1)
|
|
|
|
, color: '#fff' // #rgb or #rrggbb or array of colors
|
|
|
|
, opacity: 0.25 // Opacity of the lines
|
|
|
|
, rotate: 0 // The rotation offset
|
|
|
|
, direction: 1 // 1: clockwise, -1: counterclockwise
|
|
|
|
, speed: 1 // Rounds per second
|
|
|
|
, trail: 60 // Afterglow percentage
|
|
|
|
, fps: 20 // Frames per second when using setTimeout() as a fallback for CSS
|
|
|
|
, zIndex: 2e9 // The z-index (defaults to 2000000000)
|
|
|
|
, className: 'spinner' // The CSS class to assign to the spinner
|
|
|
|
, top: '50%' // Top position relative to parent
|
|
|
|
, left: '50%' // Left position relative to parent
|
|
|
|
, shadow: true // Whether to render a shadow
|
|
|
|
, hwaccel: true // Whether to use hardware acceleration
|
|
|
|
, position: 'relative' // Element positioning
|
|
|
|
};
|
|
|
|
UI.spinner.init = function () {
|
|
|
|
const spinner = new Spinner(UI.spinner.opts).spin(UI.spinner.elem);
|
|
|
|
};
|
2018-02-12 20:42:48 +00:00
|
|
|
UI.spinner.show = function (text) {
|
2018-02-12 18:58:00 +00:00
|
|
|
if (!UI.spinner.elem.classList.contains('active')) {
|
|
|
|
UI.spinner.elem.classList.add('active');
|
|
|
|
}
|
2018-02-12 20:42:48 +00:00
|
|
|
if (text) {
|
|
|
|
UI.message.show(text)
|
|
|
|
}
|
2018-02-12 18:58:00 +00:00
|
|
|
};
|
|
|
|
UI.spinner.hide = function () {
|
|
|
|
if (UI.spinner.elem.classList.contains('active')) {
|
|
|
|
UI.spinner.elem.classList.remove('active');
|
|
|
|
}
|
2018-02-12 20:42:48 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
UI.message = {
|
|
|
|
elem : document.getElementById('msg')
|
|
|
|
};
|
|
|
|
UI.message.show = function (text) {
|
|
|
|
UI.message.elem.innerHTML = text
|
|
|
|
if (!UI.message.elem.classList.contains('active')) {
|
|
|
|
UI.message.elem.classList.add('active');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
UI.message.hide = function () {
|
|
|
|
if (UI.message.elem.classList.contains('active')) {
|
|
|
|
UI.message.elem.classList.remove('active');
|
|
|
|
}
|
2018-02-02 20:36:28 +00:00
|
|
|
};
|
2018-02-03 21:50:14 +00:00
|
|
|
|
2018-02-02 20:36:28 +00:00
|
|
|
var init = function () {
|
2018-02-03 21:50:14 +00:00
|
|
|
document.querySelector('.angle').oninput = function () {
|
|
|
|
BOLEX.angle = parseInt(this.value);
|
|
|
|
};
|
|
|
|
document.querySelector('.iso').oninput = function () {
|
|
|
|
BOLEX.iso = parseInt(this.value);
|
|
|
|
};
|
|
|
|
document.querySelector('.fstop').oninput = function () {
|
|
|
|
BOLEX.fstop = parseFloat(this.value);
|
|
|
|
};
|
2017-11-22 16:58:02 +00:00
|
|
|
};
|