public class I2CComponent extends java.lang.Object implements Component
| Modifier and Type | Field and Description |
|---|---|
protected com.pi4j.io.i2c.I2CDevice |
device
The abstraction of the i2c device.
|
static int |
MAX_I2C_ADDRESS
The maximum available i2c device address is 0x77.
|
static int |
MIN_I2C_ADDRESS
The minimum available i2c device address is 0x03.
|
| Constructor and Description |
|---|
I2CComponent(int i2cAddress)
Constructor for a new i2c component, connected on the bus at the specific i2cAddress.
|
| Modifier and Type | Method and Description |
|---|---|
com.pi4j.io.i2c.I2CDevice |
getDevice()
Get the abstraction of the i2c device.
|
java.lang.String |
getType()
Get the String representation of the type of the component.
|
int |
readSignedRegisterValue(int reg)
Reads the content of the reg register (8bits),
and returns the signed integer representation of this value in the -128..127 interval
if read operation was successfull.
|
int |
readTwoSignedRegsiters(int reg)
Reads the signed content of two consecutive registers (reg and reg + 1) (16bits),
and returns the big endian combination of those values.
|
int |
readTwoUnsignedRegisters(int reg)
Reads the unsigned content of two consecutive registers (reg and reg + 1) (16bits),
and returns the big endian combination of those values.
|
int |
readUnsignedRegisterValue(int reg)
Reads the content of the reg register (8bits),
and returns this value in the 0..255 interval if read operation was successfull.
|
void |
writeUnsignedValueDirectlyToI2CDevice(int value)
This method writes an unsigned value directly on the i2c device
(not on a specific register on this device).
|
void |
writeUnsignedValueToRegister(int reg,
int value)
This method writes an unsigned value on the i2c device,
on a specific register of this device.
|
public static final int MAX_I2C_ADDRESS
A seven bit wide address space theoretically allows 128 I2C addresses. However, some addresses are reserved for special purposes. Only 112 addresses are then available with the 7 bit address scheme.
public static final int MIN_I2C_ADDRESS
A seven bit wide address space theoretically allows 128 I2C addresses. However, some addresses are reserved for special purposes. Thus, only 112 addresses are available with the 7 bit address scheme.
protected com.pi4j.io.i2c.I2CDevice device
public I2CComponent(int i2cAddress)
i2cAddress - the i2c device address of the corresponding component.public com.pi4j.io.i2c.I2CDevice getDevice()
I2CDevicepublic void writeUnsignedValueDirectlyToI2CDevice(int value)
value - the unsigned value to be written on the device. This value must be in the 0..255 interval.I2CDevice.write(byte)public void writeUnsignedValueToRegister(int reg,
int value)
reg - the destination register on the i2c device.value - the unsigned value to be written on the device. This value must be in the 0..255 interval.I2CDevice.write(int, byte)public int readUnsignedRegisterValue(int reg)
reg - the local address on the i2c device where the data must be read.I2CDevice.read(int),
readSignedRegisterValue(int)public int readSignedRegisterValue(int reg)
reg - the local address on the i2c device where the data must be read.readUnsignedRegisterValue(int)public int readTwoUnsignedRegisters(int reg)
reg - the local address on the i2c device of the first register to be read.readUnsignedRegisterValue(int)public int readTwoSignedRegsiters(int reg)
reg - the local address on the i2c device of the first register to be read.readUnsignedRegisterValue(int),
readSignedRegisterValue(int)