|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lejos.nxt.ColorLightSensor
public class ColorLightSensor
LEGO Color Sensor driver. This driver provides access to the LEGO Color sensor. It allows the reading of raw and processed color values. The sensor has a tri-color LED and this can be set to output red/green/blue or off. It also has a full mode in which four samples are read (off/red/green/blue) very quickly. These samples can then be combined using the calibration data provided by the device to determine the "LEGO" color currently being viewed.
Field Summary | |
---|---|
protected Colors.Color[] |
colorMap
|
protected SensorPort |
port
|
protected int |
type
|
Constructor Summary | |
---|---|
ColorLightSensor(SensorPort port,
int type)
Create a new Color Sensor instance and bind it to a port. |
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 |
int |
getBlueComponent()
|
int[] |
getColor()
Return the Red, Green and Blue values together in one array. |
Colors.Color |
getFloodlight()
Returns the color of the floodlight, including Color.NONE. |
int |
getGreenComponent()
|
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()
Returns the normalized value of the brightness of the white light detected, such that the lowest value is darkness and the highest value is intense bright light. |
int |
getRedComponent()
|
boolean |
isFloodlightOn()
Checks if the floodlight is currently on. |
Colors.Color |
readColor()
Read the current color and return an enum value. |
int |
readRawValue()
Return a single raw value from the device. |
int |
readRawValues(int[] vals)
When in full color mode this returns all four raw color values from the device by doing four very quick reads and flashing all colors. |
int |
readValue()
Return a single processed value. |
int |
readValues(int[] vals)
Return a set of calibrated data. |
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 |
void |
setType(int type)
Change the type of the sensor |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Colors.Color[] colorMap
protected SensorPort port
protected int type
Constructor Detail |
---|
public ColorLightSensor(SensorPort port, int type)
port
- Port to use for the sensor.type
- Initial operating mode.Method Detail |
---|
public void setType(int type)
type
- new sensor type.public int readRawValue()
public int readRawValues(int[] vals)
vals[ColorLightSensor.RGB_BLUE]
vals
- array of four color values.
public int readValues(int[] vals)
vals[ColorLightSensor.RGB_BLUE]
vals
- 4 element array for the results
public int readValue()
public Colors.Color readColor()
public int getLightValue()
LightDetector
getLightValue
in interface LightDetector
public int getNormalizedLightValue()
LightDetector
getNormalizedLightValue
in interface LightDetector
public void setFloodlight(boolean floodlight)
LampLightDetector
setFloodlight
in interface LampLightDetector
floodlight
- true to turn on lamp, false for off (ambient light only).public int getBlueComponent()
getBlueComponent
in interface ColorDetector
public int getGreenComponent()
getGreenComponent
in interface ColorDetector
public int[] getColor()
ColorDetector
getColor
in interface ColorDetector
public int getRedComponent()
getRedComponent
in interface ColorDetector
public Colors.Color getFloodlight()
LampLightDetector
getFloodlight
in interface LampLightDetector
public boolean isFloodlightOn()
LampLightDetector
isFloodlightOn
in interface LampLightDetector
public boolean setFloodlight(Colors.Color color)
LampLightDetector
setFloodlight
in interface LampLightDetector
color
- Use lejos.robotics.Color
enumeration constant to control lamp colors.
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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |