diff --git a/lib/bus.js b/lib/bus.js index 114b084..f557db9 100644 --- a/lib/bus.js +++ b/lib/bus.js @@ -19,4 +19,6 @@ class Bus { } // end of Bus Class -module.exports = Bus; +module.exports = { + Bus +}; diff --git a/lib/device.js b/lib/device.js index 2517975..6b6cd7e 100644 --- a/lib/device.js +++ b/lib/device.js @@ -3,48 +3,47 @@ // ********************************** class Device { -// bus is i2c-bus bus object - constructor(bus, address, opts) { - this.bus = bus.methods // artifact of adapting ic2-bus to class format - this.address = address - if (opts){ - this.id = opts.id // must be unique within a bus - this.desc = opts.desc - } - - } - - readRaw(length,buffer) { - return this.bus.i2cRead_p(this.address, length, buffer) - } - - writeRaw(length,buffer) { - return this.bus.i2cWrite_p(this.address, length, buffer) - } - - read(cmd) { - return this.bus.readByte_p(this.address, cmd) - } - - write(cmd, byte) { - return this.bus.writeByte_p(this.address, cmd, byte) - } - - - read2(cmd) { - return this.bus.readWord_p(this.address, cmd) - } - - write2(cmd, bytes) { - return this.bus.writeWord_p(this.address, cmd, bytes) - } - - // command with more than two bytes following - readBytes(){} - writeBytes(){} - - - + // bus is i2c-bus bus object + constructor(bus, address, opts) { + this.bus = bus.methods // artifact of adapting ic2-bus to class format + this.address = address + if (opts) { + this.id = opts.id // must be unique within a bus + this.desc = opts.desc } - module.exports = Device; + } + + readRaw(length, buffer) { + return this.bus.i2cRead_p(this.address, length, buffer) + } + + writeRaw(length, buffer) { + return this.bus.i2cWrite_p(this.address, length, buffer) + } + + read(cmd) { + return this.bus.readByte_p(this.address, cmd) + } + + write(cmd, byte) { + return this.bus.writeByte_p(this.address, cmd, byte) + } + + read2(cmd) { + return this.bus.readWord_p(this.address, cmd) + } + + write2(cmd, bytes) { + return this.bus.writeWord_p(this.address, cmd, bytes) + } + + // command with more than two bytes following + readBytes() {} + writeBytes() {} + +} + +module.exports = { + Device +}