From 77a10fa80a19a844c3ba3584d3a5958de3db629c Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Tue, 22 Aug 2017 00:49:08 -0400 Subject: [PATCH] Add stubb functionality for starting and stopping motor via hbridge --- lib/intval/index.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/intval/index.js b/lib/intval/index.js index 3cb32c9..57f9c82 100644 --- a/lib/intval/index.js +++ b/lib/intval/index.js @@ -9,13 +9,46 @@ class Intval { this._declarePins() } _declarePins () { - this._pin.four = gpio.export(4, { + this._pin.fwd = gpio.export(4, { direction: 'out', interval: 100, ready : () => { 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 () { return {}