Push dev work to master #2

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

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( () => {
@ -289,12 +291,15 @@ intval.frame = function (dir = null, time = null) {
setTimeout(intval._pause, intval._state.frame.open) setTimeout(intval._pause, intval._state.frame.open)
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)
} }
} }
} }