Package ftclib.robotcore
Class FtcI2cDevice
java.lang.Object
trclib.robotcore.TrcSerialBusDevice
ftclib.robotcore.FtcI2cDevice
- Direct Known Subclasses:
FtcI2cAdaFruitColorSensor
,FtcMRI2cDevice
,FtcZXDistanceSensor
This class implements a platform dependent I2C device.
-
Nested Class Summary
Nested classes/interfaces inherited from class trclib.robotcore.TrcSerialBusDevice
TrcSerialBusDevice.Request
-
Field Summary
FieldsFields inherited from class trclib.robotcore.TrcSerialBusDevice
instanceName, tracer
-
Constructor Summary
ConstructorsConstructorDescriptionFtcI2cDevice
(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress) Constructor: Creates an instance of the object.FtcI2cDevice
(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit) Constructor: Creates an instance of the object.FtcI2cDevice
(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit, boolean useRequestQueue) Constructor: Creates an instance of the object.FtcI2cDevice
(String instanceName, int i2cAddress) Constructor: Creates an instance of the object.FtcI2cDevice
(String instanceName, int i2cAddress, boolean addressIs7Bit) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
readData
(int address, int length) This method is called to read data from the device synchronously with the specified length.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.Methods inherited from class trclib.robotcore.TrcSerialBusDevice
asyncRead, asyncRead, asyncRead, asyncRead, asyncRead, asyncWrite, asyncWrite, asyncWrite, isEnabled, preemptiveWrite, sendByteCommand, sendWordCommand, setEnabled, syncRead, syncRead, syncWrite, syncWrite, toString
-
Field Details
-
deviceSynch
-
-
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
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
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 classTrcSerialBusDevice
- 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 classTrcSerialBusDevice
- 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.
-