refactoring into unified uci library
parent
29503c31af
commit
ad95a16e89
13
lib/bus.js
13
lib/bus.js
|
@ -2,19 +2,20 @@
|
||||||
|
|
||||||
const i2c = require('i2c-bus'),
|
const i2c = require('i2c-bus'),
|
||||||
pA = require('bluebird').promisifyAll,
|
pA = require('bluebird').promisifyAll,
|
||||||
PQ = require('promisqueue')
|
pQ = require('promisqueue')
|
||||||
|
|
||||||
|
// TODO Create a Bus master class then BusRPi classes etc for actual hardware.
|
||||||
|
|
||||||
class Bus {
|
class Bus {
|
||||||
constructor(busnum) {
|
constructor(busnum) {
|
||||||
this.methods = pA(i2c.open(busnum,()=>{}),{suffix: "_p" }) //,multiArgs: true})
|
this.methods = pA(i2c.open(busnum, () => {}), { suffix: "_p" }) //,multiArgs: true})
|
||||||
this.q = new PQ({ limit: 1})
|
this.q = new pQ({ limit: 1 })
|
||||||
}
|
}
|
||||||
|
|
||||||
scan(){ return this.bus.scan_p()}
|
scan() { return this.bus.scan_p() }
|
||||||
close(){ return this.bus.close_p()}
|
close() { return this.bus.close_p() }
|
||||||
|
|
||||||
qAdd(job){this.q.add(() => job)}
|
qAdd(job) { this.q.add(() => job) }
|
||||||
|
|
||||||
} // end of Bus Class
|
} // end of Bus Class
|
||||||
|
|
||||||
|
|
19
package.json
19
package.json
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "uci-template-changeme",
|
"name": "uci-i2c",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "A template for a starting a uci package",
|
"description": "Bus and Device Classes for I2C Interfacing",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"testw": "./node_modules/.bin/mocha --reporter list --recursive --watch",
|
"testw": "./node_modules/.bin/mocha --reporter list --recursive --watch",
|
||||||
|
@ -11,20 +11,19 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/uCOMmandIt/uci-pkg-template.git"
|
"url": "git+https://github.com/uCOMmandIt/i2c.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"node.js",
|
"node.js"
|
||||||
"communication",
|
|
||||||
"serial",
|
|
||||||
"utilities",
|
|
||||||
"helpers"
|
|
||||||
],
|
],
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/uCOMmandIt/utilities/issues"
|
"url": "https://github.com/uCOMmandIt/i2c/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/uCOMmandIt/utilities#readme",
|
"homepage": "https://github.com/uCOMmandIt/i2c#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"bluebird": "^3.4.7",
|
||||||
|
"i2c-bus": "^1.2.0",
|
||||||
|
"promisqueue": "^1.0.3",
|
||||||
"require-all": "git+https://github.com/dkebler/node-require-all.git#merge"
|
"require-all": "git+https://github.com/dkebler/node-require-all.git#merge"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
Loading…
Reference in New Issue