public class NXTColorSensor extends AnalogSensor implements SensorConstants, LampController, ColorIdentifier
Supported modes | |||
---|---|---|---|
Mode name | Description | unit(s) | Getter |
Color ID | Measures the color ID | Color ID | getColorIDMode() |
Red | Measures the light value when illuminated with a red light source. | N/A, normalized | getRedMode() |
Green | Measures the light value when illuminated with a green light source. | N/A, normalized | getGreenMode() |
Blue | Measures the light value when illuminated with a blue light source. | N/A, normalized | getBlueMode() |
RGB | Measures the light value when illuminated with a white light source. | N/A, normalized | getRGBMode() |
Ambient | Measures the light value of ambient light. | N/A, normalized | getAmbientMode() |
See The
leJOS sensor framework
See leJOS conventions for
SampleProviders
Modifier and Type | Field and Description |
---|---|
protected static int[] |
colorMap |
protected static long |
SWITCH_DELAY |
currentType, port
currentMode, modes
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
Constructor and Description |
---|
NXTColorSensor(AnalogPort port)
Create a new Color Sensor instance and bind it to a port.
|
NXTColorSensor(Port port)
Create a new Color Sensor instance and bind it to a port.
|
Modifier and Type | Method and Description |
---|---|
SensorMode |
getAmbientMode()
get a sample provider the returns the light value when illuminated without a
light source.
|
SensorMode |
getBlueMode()
get a sample provider the returns the light value when illuminated with a
Blue light source.
|
int |
getColorID()
Read the current color and return an enumeration constant.
|
SensorMode |
getColorIDMode()
get a sample provider in color ID mode
|
int |
getFloodlight()
Returns the color of the floodlight, including Color.NONE.
|
SensorMode |
getGreenMode()
get a sample provider the returns the light value when illuminated with a
Green light source.
|
SensorMode |
getRedMode()
get a sample provider the returns the light value when illuminated with a
Red light source.
|
SensorMode |
getRGBMode()
get a sample provider the returns the light values (RGB + ambient) when illuminated by a
white light source.
|
protected void |
init() |
boolean |
isFloodlightOn()
Checks if the floodlight is currently on.
|
protected void |
readFull() |
protected void |
readRaw() |
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.
|
normalize, NXTRawIntValue, NXTRawValue, switchType
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
close, releaseOnClose
protected static final long SWITCH_DELAY
protected static int[] colorMap
public NXTColorSensor(AnalogPort port)
port
- Port to use for the sensor.public NXTColorSensor(Port port)
port
- Port to use for the sensor.protected void init()
public SensorMode getColorIDMode()
public SensorMode getRedMode()
public SensorMode getGreenMode()
public SensorMode getBlueMode()
public SensorMode getRGBMode()
public SensorMode getAmbientMode()
protected void readRaw()
protected void readFull()
public void setFloodlight(boolean floodlight)
LampController
setFloodlight
in interface LampController
floodlight
- true to turn on lamp, false for off (ambient light only).public int getFloodlight()
LampController
getFloodlight
in interface LampController
public boolean isFloodlightOn()
LampController
isFloodlightOn
in interface LampController
public boolean setFloodlight(int color)
LampController
setFloodlight
in interface LampController
color
- Use Color
enumeration constant to control lamp colors.public int getColorID()
getColorID
in interface ColorIdentifier