|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ch.aplu.nxt.Part ch.aplu.nxt.Sensor ch.aplu.nxt.LightSensor
public class LightSensor
Class that represents a light sensor.
Field Summary |
---|
Constructor Summary | |
---|---|
LightSensor()
Creates a sensor instance connected to port S1. |
|
LightSensor(SensorPort port)
Creates a sensor instance connected to the given port. |
Method Summary | |
---|---|
void |
activate(boolean enable)
Turns on/off the LED used for reflecting light back into the sensor. |
void |
addLightListener(LightListener lightListener)
Registers the given light listener with default trigger level 500. |
void |
addLightListener(LightListener lightListener,
int triggerLevel)
Registers the given light listener for the given trigger level. |
lejos.nxt.SensorPort |
getLejosPort()
Returns the reference of the the underlying lejos.nxt.SensorPort. |
lejos.nxt.LightSensor |
getLejosSensor()
Returns the reference of the the underlying lejos.nxt.LightSensor. |
int |
getValue()
Polls the sensor. |
int |
setTriggerLevel(int triggerLevel)
Sets a new trigger level and returns the previous one. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LightSensor(SensorPort port)
port
- the port where the sensor is plugged-inpublic LightSensor()
Method Detail |
---|
public void addLightListener(LightListener lightListener, int triggerLevel)
lightListener
- the LightListener to become registered.triggerLevel
- the trigger level where the callback is triggeredpublic void addLightListener(LightListener lightListener)
lightListener
- the LightListener to become registered.public int setTriggerLevel(int triggerLevel)
triggerLevel
- the new trigger level
public void activate(boolean enable)
enable
- if true, turn the LED on, otherwise turn it offpublic int getValue()
public lejos.nxt.LightSensor getLejosSensor()
public lejos.nxt.SensorPort getLejosPort()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |