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 {
constructor () {
this._pin = {}
this._startFrame = 0
this._state = {
dir : true, //forward
running : false,
startFrame : 0
}
this._declarePins()
}
_declarePins () {
@ -53,12 +57,25 @@ class Intval {
this._pin.fwd.set(0)
this._pin.bwd.set(1)
}
_watchMicro (err, val) {
if (err) {
console.error(err)
}
}
_watchRelease (err, val) {
if (err) {
console.error(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) {
this._state.running = true
this._pin.micro.watch(this._watchMicro)
if (delay !== 0) {
setTimeout(function () {
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 () {
return {}
return this._state
}
}