node-i2c
node-i2c copied to clipboard
feat: add readbytedata method
Creating interface for i2c_smbus_read_byte_data(file, position)
.
Example (read EDID data):
const i2c = new I2C(0x50, { device: '/dev/i2c-1' }, async (error) => {
if (error) {
return console.error(error);
}
i2c.readByteDataAsync = util.promisify(i2c.readByteData);
const edid = [];
for (let i = 0; i < 256; i++) {
const byte = await i2c.readByteDataAsync(i);
edid.push(byte);
}
return console.log(edid);
});
May I suggest to consider to forward to abandonware fork
Relate-to: https://github.com/kelly/node-i2c/issues/97