Module com.pi4j

Interface I2C

All Superinterfaces:
AutoCloseable, Describable, I2CRegisterDataReader, I2CRegisterDataReaderWriter, I2CRegisterDataWriter, Identity, IO<I2C,I2CConfig,I2CProvider>, IODataReader, IODataWriter, Lifecycle, Readable
All Known Implementing Classes:
I2CBase

I2C I/O Interface for Pi4J I2C Bus/Device Communications
Version:
$Id: $Id
Author:
Robert Savage

Based on previous contributions from: Daniel Sendula, RasPelikan

  • Method Details

    • close

      void close()

      close.

      Specified by:
      close in interface AutoCloseable
    • newConfigBuilder

      static I2CConfigBuilder newConfigBuilder(Context context)

      newConfigBuilder.

      Parameters:
      context - Context
      Returns:
      a I2CConfigBuilder object.
    • device

      default int device()
      I2C Device Address
      Returns:
      The I2C device address for which this instance is constructed for.
    • bus

      default int bus()
      I2C Bus Address
      Returns:
      The I2C bus address for which this instance is constructed for.
    • isOpen

      boolean isOpen()
      I2C Device Communication State is OPEN
      Returns:
      The I2C device communication state
    • getBus

      default int getBus()
      I2C Bus Address
      Returns:
      The I2C bus address for which this instance is constructed for.
    • getDevice

      default int getDevice()
      I2C Device Address
      Returns:
      The I2C device address for which this instance is constructed for.
    • writeRead

      default int writeRead(byte[] writeBuffer, byte[] readBuffer)
      Method to perform a write of the given buffer, and then a read into the given buffer
      Parameters:
      writeBuffer - the buffer to write
      readBuffer - the buffer to read into
      Returns:
      the number of bytes read
    • writeRead

      default int writeRead(byte[] writeBuffer, int writeSize, int writeOffset, byte[] readBuffer, int readSize, int readOffset)
      Method to perform a write of the given buffer, and then a read into the given buffer
      Parameters:
      writeBuffer - the buffer to write respecting the given length and offset
      writeSize - the number of bytes to write
      writeOffset - the offset of the array to write
      readBuffer - the buffer into which to read the bytes
      readSize - the number of bytes to read
      readOffset - the offset in the read buffer at which to insert the read bytes
      Returns:
      the number of bytes read
    • getRegister

      I2CRegister getRegister(int address)
      Get an encapsulated interface for reading and writing to a specific I2C device register
      Parameters:
      address - a int.
      Returns:
      a I2CRegister object.
    • register

      default I2CRegister register(int address)
      I2C Device Register Get an encapsulated interface for reading and writing to a specific I2C device register
      Parameters:
      address - the (16-bit) device register address
      Returns:
      an instance of I2CRegister for the provided register address
    • execute

      <T> T execute(Callable<T> action)
      Executes the given runnable on the I2C bus, locking the bus for the duration of the given task
      Parameters:
      action - the action to perform, returning a value