Push dev work to master #2
|
@ -193,7 +193,7 @@ button.focus{
|
|||
}
|
||||
|
||||
#frame{
|
||||
padding: 10px 0;
|
||||
padding: 20px 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
|
@ -254,6 +254,7 @@ footer > div.selected{
|
|||
|
||||
#seq{
|
||||
margin-top: 40px;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
#overlay{
|
||||
|
|
|
@ -10,7 +10,8 @@ const STATE = {
|
|||
delay : 0,
|
||||
scale : 'ms',
|
||||
delayScale : 'ms',
|
||||
counter : 0
|
||||
counter : 0,
|
||||
sequence : false
|
||||
};
|
||||
|
||||
//functions
|
||||
|
@ -160,6 +161,12 @@ var setState = function (res) {
|
|||
exposure = shutter(STATE.exposure);
|
||||
exposureScale = scaleAuto(STATE.exposure);
|
||||
|
||||
if (res.sequence === true) {
|
||||
STATE.sequence = true;
|
||||
mobile.ble.active = true;
|
||||
document.getElementById('seq').classList.add('focus');
|
||||
}
|
||||
|
||||
document.getElementById('str').value = exposure.str;
|
||||
document.getElementById('scale').value = exposureScale;
|
||||
setExposureScale();
|
||||
|
|
|
@ -245,6 +245,40 @@ mobile.counterSuccess = function () {
|
|||
mobile.getState();
|
||||
};
|
||||
|
||||
mobile.sequence = function () {
|
||||
const opts = {
|
||||
type : 'sequence'
|
||||
};
|
||||
if (!mobile.ble.connected) {
|
||||
return alert('Not connected to an INTVAL device.');
|
||||
}
|
||||
ble.write(mobile.ble.device.id,
|
||||
mobile.ble.SERVICE_ID,
|
||||
mobile.ble.CHAR_ID,
|
||||
stringToBytes(JSON.stringify(opts)), //check length?
|
||||
mobile.frameSuccess,
|
||||
mobile.ble.onError);
|
||||
document.getElementById('seq').classList.add('focus');
|
||||
mobile.ble.active = true;
|
||||
};
|
||||
|
||||
|
||||
mobile.sequenceSuccess = function () {
|
||||
console.log('Sequence state changed');
|
||||
mobile.getState();
|
||||
setTimeout(() => {
|
||||
if (STATE.sequence) {
|
||||
mobile.ble.active = true;
|
||||
if (!document.getElementById('seq').classList.contains('focus')) {
|
||||
document.getElementById('seq').classList.add('focus');
|
||||
}
|
||||
} else {
|
||||
mobile.ble.active = false;
|
||||
document.getElementById('seq').classList.remove('focus');
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
|
||||
function bytesToString (buffer) {
|
||||
return String.fromCharCode.apply(null, new Uint8Array(buffer));
|
||||
};
|
||||
|
|
|
@ -134,6 +134,27 @@ web.setCounterSuccess = function (res) {
|
|||
forceCounter(res.counter);
|
||||
console.log(`setCounter to ${res.counter}`);
|
||||
};
|
||||
web.sequence = function () {
|
||||
const opts = {
|
||||
method : 'POST',
|
||||
headers : web._header,
|
||||
body : JSON.stringify({})
|
||||
}
|
||||
fetch('/sequence', opts)
|
||||
.then(web.useJson)
|
||||
.then(web.sequenceSuccess)
|
||||
.catch(err => {
|
||||
console.error('Error getting /sequence');
|
||||
console.error(err);
|
||||
})
|
||||
}
|
||||
web.sequenceSuccess = function (res) {
|
||||
if (res.started && res.started != false) {
|
||||
document.getElementById('seq').focus();
|
||||
} else if (res.stopped) {
|
||||
document.getElementById('seq').blur();
|
||||
}
|
||||
}
|
||||
web.useJson = function (res) {
|
||||
return res.json();
|
||||
}
|
||||
|
|
16
index.js
16
index.js
|
@ -311,7 +311,7 @@ function rSequence (req, res, next) {
|
|||
} else {
|
||||
console.time('sequence time')
|
||||
intval._state.sequence = true
|
||||
sequence.start({
|
||||
let seq_id = sequence.start({
|
||||
loop : [ (next) => {
|
||||
intval.frame(dir, exposure, (len) => {
|
||||
next()
|
||||
|
@ -324,7 +324,13 @@ function rSequence (req, res, next) {
|
|||
}, (seq) => {
|
||||
console.timeEnd('sequence time')
|
||||
})
|
||||
res.send({ started : true })
|
||||
|
||||
if (seq_id === false) {
|
||||
res.send({ started : false })
|
||||
} else {
|
||||
res.send({ started : true , id : seq_id })
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
}
|
||||
|
@ -453,12 +459,13 @@ function bSequence (obj, cb) {
|
|||
if (intval._state.sequence && sequence._state.active) {
|
||||
return sequence.setStop(() => {
|
||||
intval._state.sequence = false
|
||||
log.info('sequence stop'. { method : 'ble', id : seq_id })
|
||||
return cb()
|
||||
})
|
||||
} else {
|
||||
console.time('sequence time')
|
||||
intval._state.sequence = true
|
||||
sequence.start({
|
||||
let seq_id = sequence.start({
|
||||
loop : [ (next) => {
|
||||
intval.frame(dir, exposure, (len) => {
|
||||
next()
|
||||
|
@ -471,6 +478,9 @@ function bSequence (obj, cb) {
|
|||
}, (seq) => {
|
||||
console.timeEnd('sequence time')
|
||||
})
|
||||
if (seq_id !== false) {
|
||||
log.info('sequence start'. { method : 'ble', id : seq_id })
|
||||
}
|
||||
return cb()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue