Package lejos.hardware.sensor
Class RCXLightSensor
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.AnalogSensor
-
- lejos.hardware.sensor.RCXLightSensor
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,LampController,SampleProvider
public class RCXLightSensor extends AnalogSensor implements SensorConstants, LampController
LEGO RCX light Sensor
The RCX light sensor measures light levels of reflected or ambient light.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()
-
-
Field Summary
-
Fields inherited from class lejos.hardware.sensor.AnalogSensor
currentType, port
-
Fields inherited from class lejos.hardware.sensor.BaseSensor
currentMode, modes
-
Fields inherited from interface lejos.hardware.sensor.SensorConstants
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 Summary
Constructors Constructor Description RCXLightSensor(Port port)Create an RCX light sensor object attached to the specified port.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SensorModegetAmbientMode()get a sample provider the returns the light value when illuminated without a light source.intgetFloodlight()Returns the color of the floodlight, including Color.NONE.SensorModegetRedMode()get a sample provider the returns the light value when illuminated with a Red light source.protected voidinit()booleanisFloodlightOn()Checks if the floodlight is currently on.voidsetFloodlight(boolean floodlight)Turns the default LED light on or off.booleansetFloodlight(int color)Used to turn on or off the floodlight by color.-
Methods inherited from class lejos.hardware.sensor.AnalogSensor
normalize, NXTRawIntValue, NXTRawValue, switchType
-
Methods inherited from class lejos.hardware.sensor.BaseSensor
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
-
Methods inherited from class lejos.hardware.Device
close, releaseOnClose
-
-
-
-
Constructor Detail
-
RCXLightSensor
public RCXLightSensor(Port port)
Create an RCX light sensor object attached to the specified port. The sensor will be activated, i.e. the LED will be turned on.- Parameters:
port- port, e.g. Port.S1
-
-
Method Detail
-
init
protected void init()
-
getFloodlight
public int getFloodlight()
Description copied from interface:LampControllerReturns the color of the floodlight, including Color.NONE.- Specified by:
getFloodlightin interfaceLampController- Returns:
- An enumeration of the current color.
-
isFloodlightOn
public boolean isFloodlightOn()
Description copied from interface:LampControllerChecks if the floodlight is currently on.- Specified by:
isFloodlightOnin interfaceLampController- Returns:
- true if on, false if off.
-
setFloodlight
public void setFloodlight(boolean floodlight)
Description copied from interface:LampControllerTurns the default LED light on or off. If the sensor has more than one lamp color, this will control the red LED.- Specified by:
setFloodlightin interfaceLampController- Parameters:
floodlight- true to turn on lamp, false for off (ambient light only).
-
setFloodlight
public boolean setFloodlight(int color)
Description copied from interface:LampControllerUsed to turn on or off the floodlight by color. If the sensor has multiple light colors, you can control which color is turned on or off. If the color does not exist, it does nothing and returns false. You can turn the floodlight off by using Color.NONE.- Specified by:
setFloodlightin interfaceLampController- Parameters:
color- UseColorenumeration constant to control lamp colors.- Returns:
- True if lamp changed, false if lamp color doesn't exist for this sensor.
-
getRedMode
public SensorMode getRedMode()
get a sample provider the returns the light value when illuminated with a Red light source.- Returns:
- the sample provider
-
getAmbientMode
public SensorMode getAmbientMode()
get a sample provider the returns the light value when illuminated without a light source.- Returns:
- the sample provider
-
-