Package ftclib.archive
Class FtcMRI2cRangeSensor
java.lang.Object
trclib.robotcore.TrcSerialBusDevice
ftclib.robotcore.FtcI2cDevice
ftclib.archive.FtcMRI2cDevice
ftclib.archive.FtcMRI2cRangeSensor
- All Implemented Interfaces:
TrcSensor.DataSource<FtcMRI2cRangeSensor.DataType>
public class FtcMRI2cRangeSensor
extends FtcMRI2cDevice
implements TrcSensor.DataSource<FtcMRI2cRangeSensor.DataType>
This class implements the Modern Robotics Range Sensor extending FtcMRI2cDevice that implements the common features
of all Modern Robotics I2C devices.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class trclib.robotcore.TrcSerialBusDevice
TrcSerialBusDevice.Request
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
private static final int
private static final int
private static final int
private static final int
private static final int
Fields inherited from class ftclib.archive.FtcMRI2cDevice
MANUFACTURER_CODE, REG_COMMAND, REG_FIRMWARE_REVISION, REG_ID_CODE, REG_MANUFACTURER_CODE, REG_SET_I2C_ADDRESS
Fields inherited from class ftclib.robotcore.FtcI2cDevice
deviceSynch
Fields inherited from class trclib.robotcore.TrcSerialBusDevice
instanceName, tracer
-
Constructor Summary
ConstructorsConstructorDescriptionFtcMRI2cRangeSensor
(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit) Constructor: Creates an instance of the object.FtcMRI2cRangeSensor
(String instanceName) Constructor: Creates an instance of the object.FtcMRI2cRangeSensor
(String instanceName, int i2cAddress, boolean addressIs7Bit) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionThis method returns the optical distance.getRawData
(int index, FtcMRI2cRangeSensor.DataType dataType) This method returns the sensor data of the specified index.This method returns the ultrasonic distance.Methods inherited from class ftclib.archive.FtcMRI2cDevice
changeI2cAddress, changeI2cAddress, getFirmwareRevision, getIdCode, getManufacturerCode
Methods inherited from class ftclib.robotcore.FtcI2cDevice
readData, writeData
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
-
DEF_I2CADDRESS
public static final int DEF_I2CADDRESS- See Also:
-
REG_ULTRSONIC_DISTANCE
private static final int REG_ULTRSONIC_DISTANCE- See Also:
-
REG_OPTICAL_DISTANCE
private static final int REG_OPTICAL_DISTANCE- See Also:
-
READ_START
private static final int READ_START- See Also:
-
READ_END
private static final int READ_END- See Also:
-
READ_LENGTH
private static final int READ_LENGTH- See Also:
-
-
Constructor Details
-
FtcMRI2cRangeSensor
public FtcMRI2cRangeSensor(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.
-
FtcMRI2cRangeSensor
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.
-
FtcMRI2cRangeSensor
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.
-
-
Method Details
-
getUltrasonicDistance
This method returns the ultrasonic distance.- Returns:
- ultrasonic distance.
-
getOpticalDistance
This method returns the optical distance.- Returns:
- optical distance.
-
getRawData
This method returns the sensor data of the specified index.- Specified by:
getRawData
in interfaceTrcSensor.DataSource<FtcMRI2cRangeSensor.DataType>
- Parameters:
index
- specifies the data index.dataType
- specifies the data type.- Returns:
- sensor data of the specified index and type.
-