|
|||||||||
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
Abstraction for a NXT light sensor.
The light sensor can be calibrated to low and high values.
WARNING: THIS CLASS IS SHARED BETWEEN THE classes AND pccomms PROJECTS.
DO NOT EDIT THE VERSION IN pccomms AS IT WILL BE OVERWRITTEN WHEN THE PROJECT IS BUILT.
Field Summary |
---|
Fields inherited from interface lejos.nxt.SensorConstants |
---|
MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, TYPE_ANGLE, TYPE_CUSTOM, 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 |
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 whtn the light sensor is reading the high value - used by reaeValue |
void |
calibrateLow()
call this method when the light sensor is reading the low value - used by readValue |
int |
getHigh()
return the normalized value corresponding to readValue() = 100; |
int |
getLow()
return the normalized value corresponding to readValue() = 0 |
int |
readNormalizedValue()
Read the current sensor normalized value. |
int |
readValue()
Read the current sensor value. |
void |
setFloodlight(boolean floodlight)
Set floodlighting on or off. |
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)
floodlight
- true to set floodit mode, false for ambient light.public int readValue()
public int readNormalizedValue()
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()
public int getHigh()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |