|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lejos.nxt.LightSensor
public class LightSensor
This class is used to obtain readings from a LEGO NXT light sensor. The light sensor can be calibrated to low and high values.
Field Summary |
---|
Constructor Summary | |
---|---|
LightSensor(ADSensorPort port)
Create a light sensor object attached to the specified port. |
|
LightSensor(ADSensorPort port,
boolean floodlight)
Create a light sensor object attached to the specified port, and sets floodlighting on or off. |
Method Summary | |
---|---|
void |
calibrateHigh()
call this method when the light sensor is reading the high value - used by readValue |
void |
calibrateLow()
call this method when the light sensor is reading the low value - used by readValue |
Colors.Color |
getFloodlight()
Returns the color of the floodlight, including Color.NONE. |
int |
getHigh()
return the normalized value corresponding to readValue() = 100% |
int |
getLightValue()
Returns the calibrated and normalized brightness of the white light detected. |
int |
getLow()
return the normalized value corresponding to readValue() = 0% |
int |
getNormalizedLightValue()
Get the normalized light reading |
boolean |
isFloodlightOn()
Checks if the floodlight is currently on. |
int |
readNormalizedValue()
Get the normalized light reading |
int |
readValue()
Get the light reading |
void |
setFloodlight(boolean floodlight)
Turns the default LED light on or off. |
boolean |
setFloodlight(Colors.Color color)
Used to turn on or off the floodlight by color. |
void |
setHigh(int high)
set the normalized value corresponding to readValue() = 100% |
void |
setLow(int low)
set the normalized value corresponding to readValue() = 0% |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LightSensor(ADSensorPort port)
port
- port, e.g. Port.S1public LightSensor(ADSensorPort port, boolean floodlight)
port
- port, e.g. Port.S1floodlight
- true to set floodit mode, false for ambient light.Method Detail |
---|
public void setFloodlight(boolean floodlight)
LampLightDetector
setFloodlight
in interface LampLightDetector
floodlight
- true to turn on lamp, false for off (ambient light only).public boolean setFloodlight(Colors.Color color)
LampLightDetector
setFloodlight
in interface LampLightDetector
color
- Use lejos.robotics.Color
enumeration constant to control lamp colors.
public int getLightValue()
LightDetector
getLightValue
in interface LightDetector
public int readValue()
public int readNormalizedValue()
public int getNormalizedLightValue()
getNormalizedLightValue
in interface LightDetector
public void calibrateLow()
public void calibrateHigh()
public void setLow(int low)
low
- the low valuepublic void setHigh(int high)
high
- the high valuepublic int getLow()
getLow
in interface LightDetector
public int getHigh()
getHigh
in interface LightDetector
public Colors.Color getFloodlight()
LampLightDetector
getFloodlight
in interface LampLightDetector
public boolean isFloodlightOn()
LampLightDetector
isFloodlightOn
in interface LampLightDetector
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |