Add stubb functionality for starting and stopping motor via hbridge

This commit is contained in:
mmcwilliams 2017-08-22 00:49:08 -04:00
parent 9902702f84
commit 77a10fa80a
1 changed files with 34 additions and 1 deletions

View File

@ -9,13 +9,46 @@ class Intval {
this._declarePins() this._declarePins()
} }
_declarePins () { _declarePins () {
this._pin.four = gpio.export(4, { this._pin.fwd = gpio.export(4, {
direction: 'out', direction: 'out',
interval: 100, interval: 100,
ready : () => { ready : () => {
console.info(`Set pin 4 to OUTPUT`) console.info(`Set pin 4 to OUTPUT`)
} }
}) })
this._pin.bwd = gpio.export(5, {
direction: 'out',
interval: 100,
ready : () => {
console.info(`Set pin 5 to OUTPUT`)
}
})
}
_startFwd () {
this._pin.fwd.set(1)
this._pin.bwd.set(0)
}
_startBwd () {
this._pin.fwd.set(0)
this._pin.bwd.set(1)
}
frame (dir = true, time = 0, delay = 0) {
if (delay !== 0) {
setTimeout(function () {
if (dir) {
this._startFwd()
} else {
this._startBwd()
}
}, delay)
} else {
if (dir) {
this._startFwd()
} else {
this._startBwd()
}
}
} }
status () { status () {
return {} return {}