Package lejos.hardware.sensor
Class DexterLaserSensor
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.AnalogSensor
-
- lejos.hardware.sensor.DexterLaserSensor
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,SampleProvider
public class DexterLaserSensor extends AnalogSensor implements SensorConstants
Dexter laser sensor
The sensor contains a laser and a photodiode to read ambient light values.
The Dexter Industries laser can turn on and off very rapidly, with the following characteristics:- it takes about 8-10 ms to turn on and reach full power
- it takes about 5 ms to turn off
The code for this sensor has not been tested. Please report test results to the leJOS forum.
Supported modes Mode name Description unit(s) Getter Ambient Measures light level with the laser off N/A getAmbientMode()Laser Measures light level with the laser on N/A getLaserMode()See The leJOS sensor framework See
leJOS conventions for SampleProviders- Author:
- ?
-
-
Field Summary
Fields Modifier and Type Field Description protected static longSWITCH_DELAY-
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 DexterLaserSensor(AnalogPort port)Create a laser sensor object attached to the specified port, and sets the laser on or off.DexterLaserSensor(Port port)Create a laser sensor object attached to the specified port, and sets the laser on or off.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SensorModegetAmbientMode()Dexter laser sensor, Ambient mode
Measures light level with the laser offSensorModegetLaserMode()Dexter laser sensor, Laser mode
Measures light level with the laser onprotected voidinit()voidsetLaser(boolean laserState)-
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
-
-
-
-
Field Detail
-
SWITCH_DELAY
protected static final long SWITCH_DELAY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DexterLaserSensor
public DexterLaserSensor(AnalogPort port)
Create a laser sensor object attached to the specified port, and sets the laser on or off.- Parameters:
port- an already open analog port
-
DexterLaserSensor
public DexterLaserSensor(Port port)
Create a laser sensor object attached to the specified port, and sets the laser on or off.- Parameters:
port- port, e.g. Port.S1
-
-
Method Detail
-
init
protected void init()
-
setLaser
public void setLaser(boolean laserState)
-
getAmbientMode
public SensorMode getAmbientMode()
Dexter laser sensor, Ambient mode
Measures light level with the laser offSize and content of the sample
The sample contains one elements representing normalised (range 0-1) light level.- Returns:
- A sampleProvider
See
leJOS conventions for SampleProviders
-
getLaserMode
public SensorMode getLaserMode()
Dexter laser sensor, Laser mode
Measures light level with the laser onSize and content of the sample
The sample contains one elements representing normalised (range 0-1) light level.- Returns:
- A sampleProvider
See
leJOS conventions for SampleProviders
-
-