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 27 additions and 4 deletions
Showing only changes of commit ddf89cf6aa - Show all commits

View File

@ -33,7 +33,11 @@ const PINS = {
class Intval { class Intval {
constructor () { constructor () {
this._pin = {} this._pin = {}
this._startFrame = 0 this._state = {
dir : true, //forward
running : false,
startFrame : 0
}
this._declarePins() this._declarePins()
} }
_declarePins () { _declarePins () {
@ -53,12 +57,25 @@ class Intval {
this._pin.fwd.set(0) this._pin.fwd.set(0)
this._pin.bwd.set(1) this._pin.bwd.set(1)
} }
_watchRelease (err, val) { _watchMicro (err, val) {
if (err) { if (err) {
console.error(err); console.error(err)
} }
} }
_watchRelease (err, val) {
if (err) {
console.error(err)
}
}
setDir (val = true) {
if (typeof val !== 'boolean') {
return console.warn('Direction must be represented as either true or false')
}
this._state.dir = val
}
frame (dir = true, time = 0, delay = 0) { frame (dir = true, time = 0, delay = 0) {
this._state.running = true
this._pin.micro.watch(this._watchMicro)
if (delay !== 0) { if (delay !== 0) {
setTimeout(function () { setTimeout(function () {
if (dir) { if (dir) {
@ -76,8 +93,14 @@ class Intval {
} }
} }
} }
_stop () {
this._pin.fwd.set(0)
this._pin.bwd.set(0)
this._pin.micro.unwatch()
this._state.running = false
}
status () { status () {
return {} return this._state
} }
} }