Push dev work to master #2
|
@ -35,8 +35,12 @@ class Intval {
|
|||
this._pin = {}
|
||||
this._state = {
|
||||
dir : true, //forward
|
||||
running : false,
|
||||
startFrame : 0
|
||||
frame : {
|
||||
start : 0,
|
||||
active : false,
|
||||
val : 0,
|
||||
expected : 0
|
||||
}
|
||||
}
|
||||
this._declarePins()
|
||||
}
|
||||
|
@ -61,6 +65,8 @@ class Intval {
|
|||
if (err) {
|
||||
console.error(err)
|
||||
}
|
||||
this._state.frame.val = val
|
||||
//determine when to stop
|
||||
}
|
||||
_watchRelease (err, val) {
|
||||
if (err) {
|
||||
|
@ -74,7 +80,8 @@ class Intval {
|
|||
this._state.dir = val
|
||||
}
|
||||
frame (dir = true, time = 0, delay = 0) {
|
||||
this._state.running = true
|
||||
this._state.frame.start = +new Date()
|
||||
this._state.frame.active = true
|
||||
this._pin.micro.watch(this._watchMicro)
|
||||
if (delay !== 0) {
|
||||
setTimeout(function () {
|
||||
|
@ -96,8 +103,13 @@ class Intval {
|
|||
_stop () {
|
||||
this._pin.fwd.set(0)
|
||||
this._pin.bwd.set(0)
|
||||
|
||||
let len = (+new Date()) - this._state.frame.start
|
||||
|
||||
console.log(`Frame stopped`, { ms : len })
|
||||
|
||||
this._pin.micro.unwatch()
|
||||
this._state.running = false
|
||||
this._state.frame.active = false
|
||||
}
|
||||
status () {
|
||||
return this._state
|
||||
|
|
Loading…
Reference in New Issue