public class EV3ColorSensor extends BaseSensor implements LampController, ColorIdentifier
Sensor configuration
The flood light of the sensors can be put on or off using the setFloodlight methods.
See Sensor Product page
See The
leJOS sensors framework
See leJOS conventions for
SampleProviders
Modifier and Type | Class and Description |
---|---|
private class |
EV3ColorSensor.AmbientMode |
private class |
EV3ColorSensor.ColorIDMode |
private class |
EV3ColorSensor.RedMode |
private class |
EV3ColorSensor.RGBMode |
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
COL_AMBIENT |
protected static java.lang.String |
COL_CAL |
private static java.lang.String |
COL_COLOR |
private static java.lang.String |
COL_REFLECT |
protected static java.lang.String |
COL_REFRAW |
private static java.lang.String |
COL_RESET |
private static java.lang.String |
COL_RGBRAW |
protected static int[] |
colorMap |
private static java.lang.String |
LEGO_EV3_COLOR_SENSOR |
private static int[] |
lightColor |
protected short[] |
raw |
currentMode, currentModeS, modes, SWITCH_DELAY
ADDRESS, DEVICE, DEVICE_ROOT_PATH, LEGO_PORT, LEGO_SENSOR, MODE, PATH_DEVICE
BATTERY, BATTERY_BRICKPI, BATTERY_EV3, BATTERY_PISTORMS, LEGO_UART_SENSOR, SENSOR_MODE, SENSOR_MODES
BRICKPI, EV3BRICK, PISTORMS
Constructor and Description |
---|
EV3ColorSensor(java.lang.String portName) |
Modifier and Type | Method and Description |
---|---|
SensorMode |
getAmbientMode()
EV3 color sensors, Ambient mode
Measures the level of ambient light while the sensors lights are off. |
int |
getColorID()
Return an enumerated constant that indicates the color detected. e.g.
|
SensorMode |
getColorIDMode()
EV3 color sensors, Color ID mode
Measures the color ID of a surface. |
int |
getFloodlight()
Returns the color of the floodlight, including Color.NONE.
|
SensorMode |
getRedMode()
EV3 color sensors, Red mode
Measures the level of reflected light from the sensors RED LED. |
SensorMode |
getRGBMode()
EV3 color sensors, RGB mode
Measures the level of red, green and blue light when illuminated by a white light source.. |
private void |
initModes() |
boolean |
isFloodlightOn()
Checks if the floodlight is currently on.
|
void |
setFloodlight(boolean floodlight)
Turns the default LED light on or off.
|
boolean |
setFloodlight(int color)
Used to turn on or off the floodlight by color.
|
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes, switchMode, switchMode
detect, getIntegerAttribute, getPlatform, getStringAttribute, setIntegerAttribute, setStringAttribute
close, releaseOnClose
protected static int[] colorMap
private static final java.lang.String LEGO_EV3_COLOR_SENSOR
private static final java.lang.String COL_RESET
private static final java.lang.String COL_REFLECT
private static final java.lang.String COL_AMBIENT
private static final java.lang.String COL_COLOR
protected static final java.lang.String COL_REFRAW
private static final java.lang.String COL_RGBRAW
protected static final java.lang.String COL_CAL
private static final int[] lightColor
protected short[] raw
private void initModes()
public int getColorID()
getColorID
in interface ColorIdentifier
public void setFloodlight(boolean floodlight)
setFloodlight
in interface LampController
floodlight
- true to turn on lamp, false for off (ambient light only).public boolean isFloodlightOn()
isFloodlightOn
in interface LampController
public int getFloodlight()
getFloodlight
in interface LampController
public boolean setFloodlight(int color)
setFloodlight
in interface LampController
color
- Use Color
enumeration constant to control lamp colors.public SensorMode getColorIDMode()
Size and content of the sample
The sample contains one element containing the ID (0-7) of the detected color.
leJOS conventions for
SampleProviders
public SensorMode getRedMode()
Size and content of the sample
The sample contains one element containing the intensity level (Normalized between 0 and 1) of reflected light.
leJOS conventions for
SampleProviders
public SensorMode getAmbientMode()
Size and content of the sample
The sample contains one element containing the intensity level (Normalized between 0 and 1) of ambient light.
leJOS conventions for
SampleProviders
public SensorMode getRGBMode()
Size and content of the sample
The sample contains 3 elements containing the intensity level (Normalized between 0 and 1) of red, green and blue light respectivily.
leJOS conventions for
SampleProviders