public class NXTLightSensor extends AnalogSensor implements LampController, SensorConstants
Supported modes | |||
---|---|---|---|
Mode name | Description | unit(s) | Getter |
Red | Measures the light value when illuminated with a red light source. | N/A, normalized | getRedMode() |
Ambient | Measures the light value of ambient light. | N/A, normalized | getAmbientMode() |
Modifier and Type | Field and Description |
---|---|
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 |
---|
NXTLightSensor(AnalogPort port)
Create a light sensor object attached to the specified port.
|
NXTLightSensor(Port port)
Create a light sensor object attached to the specified port.
|
Modifier and Type | Method and Description |
---|---|
SensorMode |
getAmbientMode()
get a sample provider the returns the light value when illuminated without a
light source.
|
int |
getFloodlight()
Returns the color of the floodlight, including Color.NONE.
|
SensorMode |
getRedMode()
get a sample provider the returns the light value when illuminated with a
Red light source.
|
protected void |
init() |
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.
|
normalize, NXTRawIntValue, NXTRawValue, switchType
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
close, releaseOnClose
protected static final long SWITCH_DELAY
public NXTLightSensor(AnalogPort port)
port
- port, e.g. Port.S1public NXTLightSensor(Port port)
port
- port, e.g. Port.S1protected void init()
public void setFloodlight(boolean floodlight)
LampController
setFloodlight
in interface LampController
floodlight
- true to turn on lamp, false for off (ambient light only).public boolean setFloodlight(int color)
LampController
setFloodlight
in interface LampController
color
- Use Color
enumeration constant to control lamp colors.public int getFloodlight()
LampController
getFloodlight
in interface LampController
public boolean isFloodlightOn()
LampController
isFloodlightOn
in interface LampController
public SensorMode getRedMode()
public SensorMode getAmbientMode()