uci-i2c-device/lib/bus.js

22 lines
450 B
JavaScript
Raw Normal View History

2017-01-12 19:50:06 -08:00
'use strict'
const i2c = require('i2c-bus'),
pA = require('bluebird').promisifyAll,
PQ = require('promisqueue')
class Bus {
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()}
qAdd(job){this.q.add(() => job)}
} // end of Bus Class
module.exports = Bus;