Push dev work to master #2
9
index.js
9
index.js
|
@ -58,6 +58,7 @@ function rDir (req, res, next) {
|
|||
} else {
|
||||
dir = intval._state.frame.dir
|
||||
}
|
||||
log.info('/dir', { method: req.method, set : set, dir : dir})
|
||||
res.send({ dir : dir })
|
||||
return next()
|
||||
}
|
||||
|
@ -85,7 +86,9 @@ function rExposure (req, res, next) {
|
|||
} else {
|
||||
exposure = intval._state.frame.exposure
|
||||
}
|
||||
log.info('/exposure', { method: req.method, set : set, exposure : exposure })
|
||||
res.send({ exposure : exposure })
|
||||
return next()
|
||||
}
|
||||
|
||||
function rDelay (req, res, next) {
|
||||
|
@ -111,11 +114,15 @@ function rDelay (req, res, next) {
|
|||
} else {
|
||||
delay = intval._state.frame.delay
|
||||
}
|
||||
log.info('/delay', { method: req.method, set : set, delay : delay })
|
||||
res.send({ delay : delay })
|
||||
return next()
|
||||
}
|
||||
|
||||
function rFrame (req, res, next) {
|
||||
intval.frame()
|
||||
intval.frame(cb=()=>{
|
||||
log.info('happened')
|
||||
})
|
||||
res.send({})
|
||||
return next()
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ intval.init = function () {
|
|||
active : false, //should frame be running
|
||||
paused : false,
|
||||
exposure : 0, //length of frame exposure, in ms
|
||||
delay : 0 //delay before start of frame, in ms
|
||||
delay : 0, //delay before start of frame, in ms
|
||||
cb : () => {}
|
||||
},
|
||||
release : {
|
||||
time: 0,
|
||||
|
@ -142,6 +143,7 @@ intval._stop = function () {
|
|||
|
||||
intval._pin.micro.unwatch()
|
||||
intval._state.frame.active = false
|
||||
if (intval._state.frame.cb) intval._state.frame.cb()
|
||||
}
|
||||
/**
|
||||
* Callback for watching relese switch state changes.
|
||||
|
@ -269,7 +271,7 @@ intval.setDelay = function (val = 0) {
|
|||
* @param {?integer} [time="null"] (optional) Exposure time, 0 = minimum
|
||||
*
|
||||
*/
|
||||
intval.frame = function (dir = null, time = null) {
|
||||
intval.frame = function (dir = null, time = null, cb = () => {}) {
|
||||
if (dir === true || (dir === null && intval._state.frame.dir === true) ) {
|
||||
dir = true
|
||||
} else {
|
||||
|
@ -286,7 +288,7 @@ intval.frame = function (dir = null, time = null) {
|
|||
intval._state.frame.active = true
|
||||
intval._pin.micro.watch(intval._watchMicro)
|
||||
|
||||
log.info('frame', {dir : dir, time : time})
|
||||
log.info('frame', {dir : dir ? 'forward' : 'backward', time : time})
|
||||
|
||||
if (dir) {
|
||||
intval._startFwd()
|
||||
|
@ -312,6 +314,7 @@ intval.frame = function (dir = null, time = null) {
|
|||
}, time + intval._frame.closed)
|
||||
}
|
||||
}
|
||||
intval._state.frame.cb = cb
|
||||
}
|
||||
/**
|
||||
* Start a sequence of frames, using defaults or explicit instructions
|
||||
|
|
Loading…
Reference in New Issue