uci-i2c-device/lib/bus.js

23 lines
525 B
JavaScript

'use strict'
const i2c = require('i2c-bus'),
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 })
}
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;