From ad95a16e896608de31ea9cd4db151625224ce0dd Mon Sep 17 00:00:00 2001 From: David Kebler Date: Fri, 13 Jan 2017 19:51:55 -0800 Subject: [PATCH] refactoring into unified uci library --- lib/bus.js | 19 ++++++++++--------- package.json | 19 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/bus.js b/lib/bus.js index 05a83e4..114b084 100644 --- a/lib/bus.js +++ b/lib/bus.js @@ -1,20 +1,21 @@ 'use strict' const i2c = require('i2c-bus'), - pA = require('bluebird').promisifyAll, - PQ = require('promisqueue') + pA = require('bluebird').promisifyAll, + pQ = require('promisqueue') +// TODO Create a Bus master class then BusRPi classes etc for actual hardware. class Bus { - constructor(busnum) { - this.methods = pA(i2c.open(busnum,()=>{}),{suffix: "_p" }) //,multiArgs: true}) - this.q = new PQ({ limit: 1}) - } + constructor(busnum) { + this.methods = pA(i2c.open(busnum, () => {}), { suffix: "_p" }) //,multiArgs: true}) + this.q = new pQ({ limit: 1 }) + } -scan(){ return this.bus.scan_p()} -close(){ return this.bus.close_p()} + scan() { return this.bus.scan_p() } + close() { return this.bus.close_p() } -qAdd(job){this.q.add(() => job)} + qAdd(job) { this.q.add(() => job) } } // end of Bus Class diff --git a/package.json b/package.json index 052efb9..764c8b1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "uci-template-changeme", + "name": "uci-i2c", "version": "0.0.1", - "description": "A template for a starting a uci package", + "description": "Bus and Device Classes for I2C Interfacing", "main": "index.js", "scripts": { "testw": "./node_modules/.bin/mocha --reporter list --recursive --watch", @@ -11,20 +11,19 @@ "license": "MIT", "repository": { "type": "git", - "url": "git+https://github.com/uCOMmandIt/uci-pkg-template.git" + "url": "git+https://github.com/uCOMmandIt/i2c.git" }, "keywords": [ - "node.js", - "communication", - "serial", - "utilities", - "helpers" + "node.js" ], "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": { + "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" }, "devDependencies": {