Document intval lib

This commit is contained in:
mmcwilliams 2017-09-18 20:46:18 -04:00
parent 0fc4200f6d
commit 332399cfd7
4 changed files with 1171 additions and 23 deletions

View File

@ -8,6 +8,9 @@ Class representing the intval3 features
* [Intval](#Intval) * [Intval](#Intval)
* [._declarePins()](#Intval+_declarePins) * [._declarePins()](#Intval+_declarePins)
* [._undeclarePins()](#Intval+_undeclarePins) * [._undeclarePins()](#Intval+_undeclarePins)
* [._startFwd()](#Intval+_startFwd)
* [._startBwd()](#Intval+_startBwd)
* [._stop()](#Intval+_stop)
* [.frame(dir, time, delay)](#Intval+frame) * [.frame(dir, time, delay)](#Intval+frame)
<a name="Intval+_declarePins"></a> <a name="Intval+_declarePins"></a>
@ -24,6 +27,27 @@ Intval._undeclarePins() -
(internal function) Undeclares all Gpio in event of uncaught error (internal function) Undeclares all Gpio in event of uncaught error
that interupts the node process that interupts the node process
**Kind**: instance method of [<code>Intval</code>](#Intval)
<a name="Intval+_startFwd"></a>
### intval._startFwd()
Intval._startFwd() -
Start motor in forward direction by setting correct pins in h-bridge
**Kind**: instance method of [<code>Intval</code>](#Intval)
<a name="Intval+_startBwd"></a>
### intval._startBwd()
Intval._startBwd() -
Start motor in backward direction by setting correct pins in h-bridge
**Kind**: instance method of [<code>Intval</code>](#Intval)
<a name="Intval+_stop"></a>
### intval._stop()
Intval._stop() -
Stop motor by setting both motor pins to 0 (LOW)
**Kind**: instance method of [<code>Intval</code>](#Intval) **Kind**: instance method of [<code>Intval</code>](#Intval)
<a name="Intval+frame"></a> <a name="Intval+frame"></a>

View File

@ -79,15 +79,41 @@ class Intval {
this._pin.micro.unexport() this._pin.micro.unexport()
this._pin.release.unexport() this._pin.release.unexport()
} }
/**
* Intval._startFwd() -
* Start motor in forward direction by setting correct pins in h-bridge
*
*/
_startFwd () { _startFwd () {
this._pin.fwd.set(1) this._pin.fwd.set(1)
this._pin.bwd.set(0) this._pin.bwd.set(0)
//start high-cpu watch //start high-cpu watch
} }
/**
* Intval._startBwd() -
* Start motor in backward direction by setting correct pins in h-bridge
*
*/
_startBwd () { _startBwd () {
this._pin.fwd.set(0) this._pin.fwd.set(0)
this._pin.bwd.set(1) this._pin.bwd.set(1)
} }
/**
* Intval._stop() -
* Stop motor by setting both motor pins to 0 (LOW)
*
*/
_stop () {
this._pin.fwd.set(0)
this._pin.bwd.set(0)
let len = (+new Date()) - this._state.frame.start
console.log(`Frame stopped ${len}ms`)
this._pin.micro.unwatch()
this._state.frame.active = false
}
_watchMicro (err, val) { _watchMicro (err, val) {
/* Microswitch + 10K ohm resistor */ /* Microswitch + 10K ohm resistor */
/* 1 = open */ /* 1 = open */
@ -186,17 +212,6 @@ class Intval {
sequence () { sequence () {
console.log(`Started sequence`) console.log(`Started sequence`)
} }
_stop () {
this._pin.fwd.set(0)
this._pin.bwd.set(0)
let len = (+new Date()) - this._state.frame.start
console.log(`Frame stopped ${len}ms`)
this._pin.micro.unwatch()
this._state.frame.active = false
}
status () { status () {
return this._state return this._state
} }

1131
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "mocha tests", "test": "mocha tests",
"docs" : "sh docs.sh" "docs": "sh docs.sh"
}, },
"repository": { "repository": {
"type": "git", "type": "git",