Add beginnings of the arbitrary exposure time logic. Test with /tests/index.js file
This commit is contained in:
parent
429441137e
commit
7e989eeadf
|
@ -40,12 +40,12 @@ intval.init = function () {
|
|||
intval._state = {
|
||||
dir : true, //forward
|
||||
frame : {
|
||||
start : 0, //time frame started, timestamp
|
||||
start : 0, //time frame started, timestamp
|
||||
active : false, //should frame be running
|
||||
time : 0, //length of frame, in ms
|
||||
delay : 0, //delay before start of frame, in ms
|
||||
|
||||
expected : 1000 //expected length of frame, in ms
|
||||
time : 0, //length of frame, in ms
|
||||
delay : 0, //delay before start of frame, in ms
|
||||
open : 300, //delay before pausing frame in open state
|
||||
expected : 630 //expected length of frame, in ms
|
||||
},
|
||||
release : {
|
||||
time: 0,
|
||||
|
@ -117,6 +117,11 @@ intval._startBwd = function () {
|
|||
intval._pin.fwd.writeSync(0)
|
||||
intval._pin.bwd.writeSync(1)
|
||||
}
|
||||
|
||||
intval._pause = function () {
|
||||
intval._pin.fwd.writeSync(0)
|
||||
intval._pin.fwd.writeSync(0)
|
||||
}
|
||||
/**
|
||||
* Stop motor by setting both motor pins to 0 (LOW)
|
||||
*
|
||||
|
@ -239,6 +244,12 @@ intval.setDir = function (val = true) {
|
|||
}
|
||||
intval._state.dir = val
|
||||
}
|
||||
intval.setTime = function (val = 0) {
|
||||
intval._state.frame.time = val
|
||||
}
|
||||
intval.setDelay = function (val = 0) {
|
||||
intval._state.frame.delay = val
|
||||
}
|
||||
/**
|
||||
* Begin a single frame with set variables or defaults
|
||||
*
|
||||
|
@ -270,6 +281,14 @@ intval.frame = function (dir = null, time = null) {
|
|||
} else {
|
||||
intval._startBwd()
|
||||
}
|
||||
if (time !== null && time !== 0) {
|
||||
setTimeout(intval._pause, intval._state.frame.open)
|
||||
if (dir) {
|
||||
setTimeout(intval._startFwd, 1000)
|
||||
} else {
|
||||
setTimeout(intval._startBwd, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Start a sequence of frames, using defaults or explicit instructions
|
||||
|
|
|
@ -3,3 +3,5 @@
|
|||
const intval = require('../lib/intval')
|
||||
|
||||
intval.init()
|
||||
intval.setDir(false)
|
||||
intval.setTime(1000)
|
Loading…
Reference in New Issue