Class FtcI2cDevice

Direct Known Subclasses:
FtcI2cAdaFruitColorSensor, FtcMRI2cDevice, FtcZXDistanceSensor

public class FtcI2cDevice extends TrcSerialBusDevice
This class implements a platform dependent I2C device.
  • Field Details

  • Constructor Details

    • FtcI2cDevice

      public FtcI2cDevice(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit, boolean useRequestQueue)
      Constructor: Creates an instance of the object.
      Parameters:
      hardwareMap - specifies the global hardware map.
      instanceName - specifies the instance name.
      i2cAddress - specifies the I2C address of the device.
      addressIs7Bit - specifies true if the I2C address is a 7-bit address, false if it is 8-bit.
      useRequestQueue - specifies true to use a request queue, false otherwise.
    • FtcI2cDevice

      public FtcI2cDevice(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit)
      Constructor: Creates an instance of the object.
      Parameters:
      hardwareMap - specifies the global hardware map.
      instanceName - specifies the instance name.
      i2cAddress - specifies the I2C address of the device.
      addressIs7Bit - specifies true if the I2C address is a 7-bit address, false if it is 8-bit.
    • FtcI2cDevice

      public FtcI2cDevice(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress)
      Constructor: Creates an instance of the object.
      Parameters:
      hardwareMap - specifies the global hardware map.
      instanceName - specifies the instance name.
      i2cAddress - specifies the I2C address of the device.
    • FtcI2cDevice

      public FtcI2cDevice(String instanceName, int i2cAddress, boolean addressIs7Bit)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      i2cAddress - specifies the I2C address of the device.
      addressIs7Bit - specifies true if the I2C address is a 7-bit address, false if it is 8-bit.
    • FtcI2cDevice

      public FtcI2cDevice(String instanceName, int i2cAddress)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      i2cAddress - specifies the I2C address of the device.
  • Method Details

    • readData

      public byte[] readData(int address, int length)
      This method is called to read data from the device synchronously with the specified length.
      Specified by:
      readData in class TrcSerialBusDevice
      Parameters:
      address - specifies the data address if any, can be -1 if no address is required.
      length - specifies the number of bytes to read.
      Returns:
      a byte array containing the data read.
    • writeData

      public int writeData(int address, byte[] buffer, int length)
      This method is called to write data to the device synchronously with the specified data buffer and length.
      Specified by:
      writeData in class TrcSerialBusDevice
      Parameters:
      address - specifies the data address if any, can be -1 if no address is required.
      buffer - specifies the buffer containing the data to be written to the device.
      length - specifies the number of bytes to write.
      Returns:
      number of bytes written.