Class ColorSensorV3
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
static enum
static enum
static enum
static enum
static enum
static enum
static class
static enum
-
Constructor Summary
ConstructorDescriptionColorSensorV3
(edu.wpi.first.wpilibj.I2C.Port port) Constructs a ColorSensor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
configureColorSensor
(ColorSensorV3.ColorSensorResolution res, ColorSensorV3.ColorSensorMeasurementRate rate, ColorSensorV3.GainFactor gain) Configure the color sensor.void
configureProximitySensor
(ColorSensorV3.ProximitySensorResolution res, ColorSensorV3.ProximitySensorMeasurementRate rate) Configure the proximity sensor.void
configureProximitySensorLED
(ColorSensorV3.LEDPulseFrequency freq, ColorSensorV3.LEDCurrent curr, int pulses) Configure the the IR LED used by the proximity sensor.int
getBlue()
Get the raw color value from the blue ADCGet the color converted to CIE XYZ color space using factory calibrated constants.edu.wpi.first.wpilibj.util.Color
getColor()
Get the most likely color.int
getGreen()
Get the raw color value from the green ADCint
getIR()
Get the raw color value from the IR ADCint
Get the raw proximity value from the sensor ADC (11 bit).Get the raw color values from their respective ADCs (20-bit).int
getRed()
Get the raw color value from the red ADCboolean
hasReset()
Indicates if the device reset.boolean
Indicates if the device can currently be communicated with.
-
Constructor Details
-
ColorSensorV3
Constructs a ColorSensor.- Parameters:
port
- The I2C port the color sensor is attached to
-
-
Method Details
-
configureProximitySensorLED
public void configureProximitySensorLED(ColorSensorV3.LEDPulseFrequency freq, ColorSensorV3.LEDCurrent curr, int pulses) Configure the the IR LED used by the proximity sensor.These settings are only needed for advanced users, the defaults will work fine for most teams. Consult the APDS-9151 for more information on these configuration settings and how they will affect proximity sensor measurements.
- Parameters:
freq
- The pulse modulation frequency for the proximity sensor LEDcurr
- The pulse current for the proximity sensor LEDpulses
- The number of pulses per measurement of the proximity sensor LED (0-255)
-
configureProximitySensor
public void configureProximitySensor(ColorSensorV3.ProximitySensorResolution res, ColorSensorV3.ProximitySensorMeasurementRate rate) Configure the proximity sensor.These settings are only needed for advanced users, the defaults will work fine for most teams. Consult the APDS-9151 for more information on these configuration settings and how they will affect proximity sensor measurements.
- Parameters:
res
- Bit resolution output by the proximity sensor ADC.rate
- Measurement rate of the proximity sensor
-
configureColorSensor
public void configureColorSensor(ColorSensorV3.ColorSensorResolution res, ColorSensorV3.ColorSensorMeasurementRate rate, ColorSensorV3.GainFactor gain) Configure the color sensor.These settings are only needed for advanced users, the defaults will work fine for most teams. Consult the APDS-9151 for more information on these configuration settings and how they will affect color sensor measurements.
- Parameters:
res
- Bit resolution output by the respective light sensor ADCsrate
- Measurement rate of the light sensorgain
- Gain factor applied to light sensor (color) outputs
-
getColor
Get the most likely color. Works best when within 2 inches and perpendicular to surface of interest.- Returns:
- Color enum of the most likely color, including unknown if the minimum threshold is not met
-
getProximity
Get the raw proximity value from the sensor ADC (11 bit). This value is largest when an object is close to the sensor and smallest when far away.- Returns:
- Proximity measurement value, ranging from 0 to 2047
-
getRawColor
Get the raw color values from their respective ADCs (20-bit).- Returns:
- ColorValues struct containing red, green, blue and IR values
-
getRed
Get the raw color value from the red ADC- Returns:
- Red ADC value
-
getGreen
Get the raw color value from the green ADC- Returns:
- Green ADC value
-
getBlue
Get the raw color value from the blue ADC- Returns:
- Blue ADC value
-
getIR
Get the raw color value from the IR ADC- Returns:
- IR ADC value
-
getCIEColor
Get the color converted to CIE XYZ color space using factory calibrated constants.https://en.wikipedia.org/wiki/CIE_1931_color_space
- Returns:
- CIEColor value from sensor
-
hasReset
Indicates if the device reset. Based on the power on status flag in the status register. Per the datasheet:Part went through a power-up event, either because the part was turned on or because there was power supply voltage disturbance (default at first register read).
This flag is self clearing
- Returns:
- true if the device was reset
-
isConnected
Indicates if the device can currently be communicated with.- Returns:
- true if the device is currently connected and responsive
-