readByte method
Reads a byte from the I2C device with the address
. The optional register
parameters bit order
/width
enables 16-bit register.
Some I2C devices can directly be read without explicit register.
The bit order
depends on the I2C device.
Implementation
int readByte(int address) {
var data = <I2Cmsg>[];
data.add(I2Cmsg(address, [I2CmsgFlags.i2c_m_rd], 1));
var result = transfer(data);
try {
var ptr = result._messages[0].buf;
var value = ptr[0];
return value;
} finally {
result.dispose();
}
}