Harden the logic which allows exposures at arbitrary exposure times. A "pause" variable has been added to the frame state that tracks when the frame is intentionally paused, preventing the premature pausing of a single frame.

This commit is contained in:
mmcw-dev 2017-10-20 20:19:29 -04:00
parent ef77ecce83
commit 243f45c836
1 changed files with 9 additions and 4 deletions

View File

@ -42,6 +42,7 @@ intval.init = function () {
frame : { frame : {
start : 0, //time frame started, timestamp start : 0, //time frame started, timestamp
active : false, //should frame be running active : false, //should frame be running
paused : false,
time : 0, //length of frame, in ms time : 0, //length of frame, in ms
delay : 0, //delay before start of frame, in ms delay : 0, //delay before start of frame, in ms
open : 300, //delay before pausing frame in open state open : 300, //delay before pausing frame in open state
@ -121,6 +122,7 @@ intval._startBwd = function () {
intval._pause = function () { intval._pause = function () {
intval._pin.fwd.writeSync(0) intval._pin.fwd.writeSync(0)
intval._pin.fwd.writeSync(0) intval._pin.fwd.writeSync(0)
intval._state.micro.paused = true
} }
/** /**
* Stop motor by setting both motor pins to 0 (LOW) * Stop motor by setting both motor pins to 0 (LOW)
@ -167,7 +169,7 @@ intval._watchMicro = function (err, val) {
log.info('Microswitch primed to stop motor') log.info('Microswitch primed to stop motor')
} }
} else if (val === 1 && intval._state.frame.active) { } else if (val === 1 && intval._state.frame.active) {
if (intval._state.micro.primed) { if (intval._state.micro.primed && !intval._state.micro.paused) {
intval._state.micro.primed = false intval._state.micro.primed = false
intval._state.micro.time = 0 intval._state.micro.time = 0
//setTimeout( () => { //setTimeout( () => {
@ -290,11 +292,14 @@ intval.frame = function (dir = null, time = null) {
if (dir) { if (dir) {
log.info('frame', { pausing : time - intval._state.frame.open }) log.info('frame', { pausing : time - intval._state.frame.open })
setTimeout( () => { setTimeout( () => {
log.info('frame', 'restarting after pause') intval._state.frame.paused = false
intval._startFwd() intval._startFwd()
}, time - intval._state.frame.open) }, time - intval._state.frame.open)
} else { } else {
setTimeout(intval._startBwd, time - intval._state.frame.open) setTimeout( () => {
intval._state.frame.paused = false
intval._startBwd()
}, time - intval._state.frame.open)
} }
} }
} }