Push dev work to master #2

Merged
sixteenmillimeter merged 416 commits from dev into master 2018-07-19 15:29:02 +00:00
3 changed files with 55 additions and 4 deletions
Showing only changes of commit a9e13ac2a6 - Show all commits

View File

@ -322,7 +322,13 @@ null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"
};
web.getStateSuccess = function (res) {
'use strict';
console.dir(res);
if (res.frame.dir !== true) {
$('#dir').prop('checked', true);
setDirLabel(false);
}
$('#counter').val(res.counter);
$('#exposure').val(res.frame.exposure);
$('#delay').val(res.frame.delay);
};
web.init = function () {
'use strict';
@ -330,6 +336,7 @@ null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"
getState = web.getState;
setDir = web.setDir;
setExposure = web.setExposure;
web.getState();
};
web.init();

View File

@ -25,6 +25,8 @@ function createServer () {
app.post('/dir', rDir)
app.get( '/exposure', rExposure)
app.post('/exposure', rExposure)
app.get( '/counter', rCounter)
app.post('/counter', rCounter)
app.get( '/frame', rFrame)
app.post('/frame', rFrame)
app.get( '/sequence', () => {})
@ -119,6 +121,35 @@ function rDelay (req, res, next) {
return next()
}
function rCounter (req, res, next) {
let counter = 0
let set = false
if (req.query && typeof req.query.counter !== 'undefined') {
if (typeof req.query.counter === 'string') {
counter = parseInt(req.query.counter)
} else {
counter = req.query.counter
}
set = true
}
if (req.body && typeof req.body.counter !== 'undefined') {
if (typeof req.body.counter !== 'string') {
counter = parseInt(req.body.counter)
} else {
counter = req.body.counter
}
set = true
}
if (set) {
intval.setCounter(counter)
} else {
counter = intval._state.counter
}
log.info('/counter', { method : req.method, set : set, counter : counter })
req.send({ counter : counter })
return next()
}
function rFrame (req, res, next) {
let dir = true
let exposure = 0

View File

@ -54,7 +54,8 @@ intval.init = function () {
micro : {
time : 0,
primed : false //is ready to stop frame
}
},
counter : 0
}
intval._frame = {
open : 250, //delay before pausing frame in open state
@ -264,6 +265,10 @@ intval.setDelay = function (val = 0) {
intval._state.frame.delay = val
log.info('setDelay', { delay : val })
}
intval.setCounter = function (val = 0) {
intval._state.counter = val
log.info('setCounter', { counter : val })
}
/**
* Begin a single frame with set variables or defaults
*
@ -313,9 +318,17 @@ intval.frame = function (dir = null, time = null, cb = () => {}) {
}, time + intval._frame.closed)
}
}
if (dir) {
intval._state.frame.cb = (len) => {
intval._state.counter++
cb(len)
}
} else {
intval._state.frame.cb = (len) => {
intval._state.counter--
cb(len)
}
}
}
/**
* Start a sequence of frames, using defaults or explicit instructions