Package ftclib.sensor
Class FtcI2cAdaFruitColorSensor
java.lang.Object
trclib.robotcore.TrcSerialBusDevice
ftclib.robotcore.FtcI2cDevice
ftclib.sensor.FtcI2cAdaFruitColorSensor
- All Implemented Interfaces:
TrcSensor.DataSource<FtcI2cAdaFruitColorSensor.DataType>
public class FtcI2cAdaFruitColorSensor
extends FtcI2cDevice
implements TrcSensor.DataSource<FtcI2cAdaFruitColorSensor.DataType>
This class implements the AdaFruit Color Sensor extending FtcI2cDevice.
-
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 byte
private static final byte
private static final byte
private static final byte
private static final byte
private final TrcSensor.SensorData<Integer>
private final TrcSensor.SensorData<Integer>
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
static final int
private int
private static final byte
private static final byte
private static final byte
private static final byte
private final TrcSensor.SensorData<Integer>
private static final int
private static final int
private static final int
private final TrcSensor.SensorData<Integer>
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
Fields inherited from class ftclib.robotcore.FtcI2cDevice
deviceSynch
Fields inherited from class trclib.robotcore.TrcSerialBusDevice
instanceName, tracer
-
Constructor Summary
ConstructorsConstructorDescriptionFtcI2cAdaFruitColorSensor
(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit) Constructor: Creates an instance of the object.FtcI2cAdaFruitColorSensor
(String instanceName) Constructor: Creates an instance of the object.FtcI2cAdaFruitColorSensor
(String instanceName, int i2cAddress, boolean addressIs7Bit) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionThis method returns the blue value.This method returns the clear value.This method returns the green value.int
getID()
This method returns the device ID.getRawData
(int index, FtcI2cAdaFruitColorSensor.DataType dataType) This method returns the sensor data of the specified index.This method returns the red value.int
This method returns the device status.void
setAGain
(byte aGain) This method sets the RGBC gain control.void
setATime
(byte aTime) This method sets the RGBC time.void
setClearInterruptHighThreshold
(short threshold) This method sets the high threshold for the Clear Interrupt.void
setClearInterruptLowThreshold
(short threshold) This method sets the low threshold for the Clear Interrupt.void
setSensorEnabled
(boolean enabled) This method enables/disables the sensor.void
setWTime
(byte wTime) This method sets the wait time.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:
-
ALTERNATE_I2CADDRESS
public static final int ALTERNATE_I2CADDRESS- See Also:
-
REG_COMMAND_BIT
private static final int REG_COMMAND_BIT- See Also:
-
REG_ENABLE
private static final int REG_ENABLE- See Also:
-
REG_ATIME
private static final int REG_ATIME- See Also:
-
REG_WTIME
private static final int REG_WTIME- See Also:
-
REG_AILTL
private static final int REG_AILTL- See Also:
-
REG_AILTH
private static final int REG_AILTH- See Also:
-
REG_AIHTL
private static final int REG_AIHTL- See Also:
-
REG_AIHTH
private static final int REG_AIHTH- See Also:
-
REG_PERS
private static final int REG_PERS- See Also:
-
REG_CONFIG
private static final int REG_CONFIG- See Also:
-
REG_CONTROL
private static final int REG_CONTROL- See Also:
-
REG_ID
private static final int REG_ID- See Also:
-
REG_STATUS
private static final int REG_STATUS- See Also:
-
REG_CDATAL
private static final int REG_CDATAL- See Also:
-
REG_CDATAH
private static final int REG_CDATAH- See Also:
-
REG_RDATAL
private static final int REG_RDATAL- See Also:
-
REG_RDATAH
private static final int REG_RDATAH- See Also:
-
REG_GDATAL
private static final int REG_GDATAL- See Also:
-
REG_GDATAH
private static final int REG_GDATAH- See Also:
-
REG_BDATAL
private static final int REG_BDATAL- See Also:
-
REG_BDATAH
private static final int REG_BDATAH- 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:
-
ENABLE_PON
private static final byte ENABLE_PON- See Also:
-
ENABLE_AEN
private static final byte ENABLE_AEN- See Also:
-
ENABLE_WEN
private static final byte ENABLE_WEN- See Also:
-
ENABLE_AIEN
private static final byte ENABLE_AIEN- See Also:
-
ATIME_1_CYCLE
private static final byte ATIME_1_CYCLE- See Also:
-
ATIME_10_CYCLE
private static final byte ATIME_10_CYCLE- See Also:
-
ATIME_42_CYCLE
private static final byte ATIME_42_CYCLE- See Also:
-
ATIME_64_CYCLE
private static final byte ATIME_64_CYCLE- See Also:
-
ATIME_256_CYCLE
private static final byte ATIME_256_CYCLE- See Also:
-
WTIME_1_CYCLE
private static final byte WTIME_1_CYCLE- See Also:
-
WTIME_85_CYCLE
private static final byte WTIME_85_CYCLE- See Also:
-
WTIME_256_CYCLE
private static final byte WTIME_256_CYCLE- See Also:
-
CONFIG_WLONG
private static final byte CONFIG_WLONG- See Also:
-
CONTROL_AGAIN_1X
private static final byte CONTROL_AGAIN_1X- See Also:
-
CONTROL_AGAIN_4X
private static final byte CONTROL_AGAIN_4X- See Also:
-
CONTROL_AGAIN_16X
private static final byte CONTROL_AGAIN_16X- See Also:
-
CONTROL_AGAIN_60X
private static final byte CONTROL_AGAIN_60X- See Also:
-
STATUS_AVALID
private static final byte STATUS_AVALID- See Also:
-
STATUS_AINT
private static final byte STATUS_AINT- See Also:
-
deviceID
private int deviceID -
clearValue
-
redValue
-
greenValue
-
blueValue
-
-
Constructor Details
-
FtcI2cAdaFruitColorSensor
public FtcI2cAdaFruitColorSensor(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.
-
FtcI2cAdaFruitColorSensor
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.
-
FtcI2cAdaFruitColorSensor
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.
-
-
Method Details
-
setSensorEnabled
public void setSensorEnabled(boolean enabled) This method enables/disables the sensor.- Parameters:
enabled
- specifies true to enable sensor, false otherwise.
-
setATime
public void setATime(byte aTime) This method sets the RGBC time.- Parameters:
aTime
- specifies the RGBC time cycles (see ATIME_*).
-
setWTime
public void setWTime(byte wTime) This method sets the wait time.- Parameters:
wTime
- specifies the wait time cycles (see WTIME_*).
-
setClearInterruptLowThreshold
public void setClearInterruptLowThreshold(short threshold) This method sets the low threshold for the Clear Interrupt.- Parameters:
threshold
- specifies the low threshold value.
-
setClearInterruptHighThreshold
public void setClearInterruptHighThreshold(short threshold) This method sets the high threshold for the Clear Interrupt.- Parameters:
threshold
- specifies the high threshold value.
-
setAGain
public void setAGain(byte aGain) This method sets the RGBC gain control.- Parameters:
aGain
- specifies the RGBC gain value.
-
getID
public int getID()This method returns the device ID.- Returns:
- device ID.
-
getStatus
public int getStatus()This method returns the device status.- Returns:
- device status.
-
getClearValue
This method returns the clear value.- Returns:
- clear value.
-
getRedValue
This method returns the red value.- Returns:
- red value.
-
getGreenValue
This method returns the green value.- Returns:
- green value.
-
getBlueValue
This method returns the blue value.- Returns:
- blue value.
-
getRawData
public TrcSensor.SensorData<Integer> getRawData(int index, FtcI2cAdaFruitColorSensor.DataType dataType) This method returns the sensor data of the specified index.- Specified by:
getRawData
in interfaceTrcSensor.DataSource<FtcI2cAdaFruitColorSensor.DataType>
- Parameters:
index
- specifies the data index.dataType
- specifies the data type to return (e.g. rotation rate or heading of a gyro axis).- Returns:
- sensor data of the specified index.
-