The class I2C
For accessing the I²C bus, JControl devices provide the class
jcontrol.comm.I2C, which implements the methods
write to acquire or send single characters or complete
byte arrays via the I²C bus. When instantiating this class, the slave address of the connected I²C component is passed as a constructor parameter. A detailed description of the
I2C methods may be seen in the API documentation.
The following Table conveys a short overview of the methods of the class
Table 2: General methods for communicating with I²C components
|Used to create an instance of the class
I2C. This is related to the connected hardware by the given slave
read(byte data, int index, int length)
|Reads (status) data from the I²C periphery and writes it into the passed byte array
data. The array will be filled with the specified amount of bytes (
length), beginning at array position
|Sends data or commands to the I²C periphery.
To keep the example as simple as possible, the class
LM75 will be implemented during the next section. This extends the class I²C and takes care of the the communication with the periphery.