refactoring into unified uci library

master
David Kebler 2017-01-13 19:51:55 -08:00
parent 29503c31af
commit ad95a16e89
2 changed files with 19 additions and 19 deletions

View File

@ -1,20 +1,21 @@
'use strict' 'use strict'
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

View File

@ -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": {