kelly / node-i2c

Node.js native bindings for i2c-dev. Plays well with Raspberry Pi and Beaglebone.
Other
216 stars 91 forks source link

feat: add readbytedata method #89

Open matheussampaio opened 7 years ago

matheussampaio commented 7 years ago

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);
});
rzr commented 4 years ago

May I suggest to consider to forward to abandonware fork

Relate-to: https://github.com/kelly/node-i2c/issues/97