Package ftclib.archive
Class FtcMRI2cColorSensor
java.lang.Object
trclib.robotcore.TrcSerialBusDevice
ftclib.robotcore.FtcI2cDevice
ftclib.archive.FtcMRI2cDevice
ftclib.archive.FtcMRI2cColorSensor
- All Implemented Interfaces:
TrcSensor.DataSource<FtcMRI2cColorSensor.DataType>
public class FtcMRI2cColorSensor
extends FtcMRI2cDevice
implements TrcSensor.DataSource<FtcMRI2cColorSensor.DataType>
This class implements the Modern Robotics Color 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 TypeFieldDescriptionprivate static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
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
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
ConstructorsConstructorDescriptionFtcMRI2cColorSensor
(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit) Constructor: Creates an instance of the object.FtcMRI2cColorSensor
(String instanceName) Constructor: Creates an instance of the object.FtcMRI2cColorSensor
(String instanceName, int i2cAddress, boolean addressIs7Bit) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This method calibrates the black level.void
This method calibrates the white balance.This method returns the blue value.This method returns the color number.This method returns the green value.getRawData
(int index, FtcMRI2cColorSensor.DataType dataType) This method returns the sensor data of the specified index.This method returns the red value.This method returns the white value.void
This method sets the operating frequency to 50Hz.void
This method sets the operating frequency to 60Hz.void
setLEDEnabled
(boolean enabled) This method turns on the internal LED to illuminate the target surface or turns off the internal LED and reads from external light sources.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_COLOR_NUMBER
private static final int REG_COLOR_NUMBER- See Also:
-
REG_RED
private static final int REG_RED- See Also:
-
REG_GREEN
private static final int REG_GREEN- See Also:
-
REG_BLUE
private static final int REG_BLUE- See Also:
-
REG_WHITE
private static final int REG_WHITE- 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:
-
CMD_ENABLE_LED
private static final byte CMD_ENABLE_LED- See Also:
-
CMD_DISABLE_LED
private static final byte CMD_DISABLE_LED- See Also:
-
CMD_SET_50HZ_MODE
private static final byte CMD_SET_50HZ_MODE- See Also:
-
CMD_SET_60HZ_MODE
private static final byte CMD_SET_60HZ_MODE- See Also:
-
CMD_CAL_BLACKLEVEL
private static final byte CMD_CAL_BLACKLEVEL- See Also:
-
CMD_CAL_WHITEBAL
private static final byte CMD_CAL_WHITEBAL- See Also:
-
COLORNUM_BLACK
private static final byte COLORNUM_BLACK- See Also:
-
COLORNUM_PURPLE
private static final byte COLORNUM_PURPLE- See Also:
-
COLORNUM_PURPLE_BLUE
private static final byte COLORNUM_PURPLE_BLUE- See Also:
-
COLORNUM_BLUE
private static final byte COLORNUM_BLUE- See Also:
-
COLORNUM_BLUE_GREEN
private static final byte COLORNUM_BLUE_GREEN- See Also:
-
COLORNUM_GREEN
private static final byte COLORNUM_GREEN- See Also:
-
COLORNUM_GREEN_YELLOW
private static final byte COLORNUM_GREEN_YELLOW- See Also:
-
COLORNUM_YELLOW
private static final byte COLORNUM_YELLOW- See Also:
-
COLORNUM_YELLOW_ORANGE
private static final byte COLORNUM_YELLOW_ORANGE- See Also:
-
COLORNUM_ORANGE
private static final byte COLORNUM_ORANGE- See Also:
-
COLORNUM_ORANGE_RED
private static final byte COLORNUM_ORANGE_RED- See Also:
-
COLORNUM_RED
private static final byte COLORNUM_RED- See Also:
-
COLORNUM_PINK
private static final byte COLORNUM_PINK- See Also:
-
COLORNUM_LIGHT_PINK
private static final byte COLORNUM_LIGHT_PINK- See Also:
-
COLORNUM_LIGHT_YELLOW
private static final byte COLORNUM_LIGHT_YELLOW- See Also:
-
COLORNUM_LIGHT_BLUE
private static final byte COLORNUM_LIGHT_BLUE- See Also:
-
COLORNUM_WHITE
private static final byte COLORNUM_WHITE- See Also:
-
-
Constructor Details
-
FtcMRI2cColorSensor
public FtcMRI2cColorSensor(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.
-
FtcMRI2cColorSensor
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.
-
FtcMRI2cColorSensor
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.
-
-
Method Details
-
setLEDEnabled
public void setLEDEnabled(boolean enabled) This method turns on the internal LED to illuminate the target surface or turns off the internal LED and reads from external light sources.- Parameters:
enabled
- specifies true to turn on internal LED, false otherwise.
-
set50HzMode
public void set50HzMode()This method sets the operating frequency to 50Hz. This setting is saved in EEPROM. This function is provided to enable the sampling to coincide with the normal flickering associated with mains electrical A/C artificial lighting, and helps minimize signal noise issues. Call this method when used in countries with 50Hz A/C electric current frequency. When Frequency Mode set is complete, the LED will blink off briefly and then the previous measurement mode will resume. -
set60HzMode
public void set60HzMode()This method sets the operating frequency to 60Hz. This setting is saved in EEPROM. This function is provided to enable the sampling to coincide with the normal flickering associated with mains electrical A/C artificial lighting, and helps minimize signal noise issues. Call this method when used in countries with 60Hz A/C electric current frequency. When Frequency Mode set is complete, the LED will blink off briefly and then the previous measurement mode will resume. -
calibrateBlackLevel
public void calibrateBlackLevel()This method calibrates the black level. It runs 64 measurement cycles to obtain an average value for each of the 3 color channels. The three values obtained are stored in EEPROM and will subsequently be subtracted from all future measurements. When the black level calibration is complete, the LED will blink off briefly and then the previous measurement mode will resume with the command byte being set to 00H or 01H. During the black level calibration, the sensor should be placed such that no surface is within 5 feet (1.5m) of the sensor element. -
calibrateWhiteBalance
public void calibrateWhiteBalance()This method calibrates the white balance. It runs 64 measurement cycles to obtain an average value for each of the 3 color channels. The values obtained are adjusted according to the stored black level calibration values and stored in EEPROM. When the white balance calibration is complete, the LED will blink off briefly and then previous measurement mode will resume. During white balance calibration, the sensor must be placed approximately 2 inches (5cm) from a white target. This target must be as white as possible. At least 3 layers of high quality copy paper make a good white target. -
getColorNumber
This method returns the color number.- Returns:
- color number.
-
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.
-
getWhiteValue
This method returns the white value.- Returns:
- white value.
-
getRawData
This method returns the sensor data of the specified index.- Specified by:
getRawData
in interfaceTrcSensor.DataSource<FtcMRI2cColorSensor.DataType>
- Parameters:
index
- specifies the data index.dataType
- specifies the data type.- Returns:
- sensor data of the specified index and type.
-