All features added to /frame endpoint, can set direction independent of the state and can set the exposure as well.

This commit is contained in:
mmcw-dev 2017-10-21 20:12:39 -04:00
parent da3908c2e5
commit d7ca2ebe46
2 changed files with 40 additions and 4 deletions

View File

@ -120,9 +120,45 @@ function rDelay (req, res, next) {
} }
function rFrame (req, res, next) { function rFrame (req, res, next) {
log.info('/frame', { method : req.method }) let dir = true
intval.frame(true, 0, (dir, len) => { let exposure = 0
res.send({ dir : true, len : len}) if (intval._state.frame.dir !== true) {
dir = false
}
if (intval._state.frame.exposure !== 0) {
exposure = intval._state.frame.exposure
}
if (req.query && typeof req.query.dir !== 'undefined') {
if (typeof req.query.dir === 'string') {
dir = (req.query.dir === 'true')
} else {
dir = req.query.dir
}
}
if (req.body && typeof req.body.dir !== 'undefined') {
if (typeof req.body.dir === 'string') {
dir = (req.body.dir === 'true')
} else {
dir = req.body.dir
}
}
if (req.query && typeof req.query.exposure !== 'undefined') {
if (typeof req.query.exposure === 'string') {
exposure = parseInt(req.query.exposure)
} else {
exposure = req.query.exposure
}
}
if (req.body && typeof req.body.exposure !== 'undefined') {
if (typeof req.body.exposure === 'string') {
exposure = parseInt(req.body.exposure)
} else {
exposure = req.body.exposure
}
}
log.info('/frame', { method : req.method, dir : dir, exposure : exposure })
intval.frame(dir, exposure, (len) => {
res.send({ dir : dir, len : len})
return next() return next()
}) })
} }

View File

@ -314,7 +314,7 @@ intval.frame = function (dir = null, time = null, cb = () => {}) {
} }
} }
intval._state.frame.cb = (len) => { intval._state.frame.cb = (len) => {
cb(dir, len) cb(len)
} }
} }
/** /**