Push dev work to master #2

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

View File

@ -287,6 +287,20 @@ function rSequence (req, res, next) {
exposure = req.body.exposure exposure = req.body.exposure
} }
} }
if (req.query && typeof req.query.delay !== 'undefined') {
if (typeof req.query.delay === 'string') {
delay = parseInt(req.query.delay)
} else {
delay = req.query.delay
}
}
if (req.body && typeof req.body.delay!== 'undefined') {
if (typeof req.body.delay === 'string') {
delay = parseInt(req.body.delay)
} else {
delay = req.body.delay
}
}
if (intval._state.sequence && sequence._state.active) { if (intval._state.sequence && sequence._state.active) {
return sequence.setStop(() => { return sequence.setStop(() => {
intval._state.sequence = false intval._state.sequence = false
@ -465,6 +479,31 @@ function bReset (obj, cb) {
setTimeout(cb, 10) setTimeout(cb, 10)
} }
function seq () {
if (intval._state.sequence && sequence._state.active) {
return sequence.setStop(() => {
intval._state.sequence = false
return cb()
})
} else {
console.time('sequence time')
intval._state.sequence = true
sequence.start({
loop : [ (next) => {
intval.frame(dir, exposure, (len) => {
next()
})
}, (next) => {
setTimeout(() => {
next()
}, delay)
}]
}, (seq) => {
console.timeEnd('sequence time')
})
}
}
function index (req, res, next) { function index (req, res, next) {
fs.readFile(INDEXPATH, 'utf8', (err, data) => { fs.readFile(INDEXPATH, 'utf8', (err, data) => {
if (err) { if (err) {
@ -477,6 +516,7 @@ function index (req, res, next) {
function init () { function init () {
intval.init() intval.init()
intval.sequence = seq
createServer() createServer()
createBLE() createBLE()
} }

View File

@ -412,13 +412,7 @@ intval.frame = function (dir = null, exposure = null, cb = () => {}) {
exposure: exposure exposure: exposure
} }
} }
/**
* Start a sequence of frames, using defaults or explicit instructions
*
*/
intval.sequence = function () {
log.info('sequence', `Started sequence`)
}
intval.status = function () { intval.status = function () {
return intval._state return intval._state
} }