22 lines
450 B
JavaScript
22 lines
450 B
JavaScript
|
'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;
|