|
|||||||||
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.I2CSensor ch.aplu.nxt.UltrasonicSensor
public class UltrasonicSensor
Class that represents an ultrasonic sensor. Most of the code and the documentation taken from the leJOS library (lejos.sourceforge.net, with thanks to the autor.
Field Summary |
---|
Constructor Summary | |
---|---|
UltrasonicSensor()
Creates a sensor instance connected to port S1. |
|
UltrasonicSensor(SensorPort port)
Creates a sensor instance connected to the given port. |
Method Summary | |
---|---|
void |
addUltrasonicListener(UltrasonicListener ultrasonicListener)
Registers the given ultrasonic listener with default trigger level 20. |
void |
addUltrasonicListener(UltrasonicListener ultrasonicListener,
int triggerLevel)
Registers the given ultrasonic listener for the given trigger level. |
int |
getDistance()
Polls the sensor. |
lejos.nxt.UltrasonicSensor |
getLejosSensor()
Returns the reference of the the underlying lejos.nxt.UltrasonicSensor. |
int |
setTriggerLevel(int triggerLevel)
Sets a new trigger level and returns the previous one. |
Methods inherited from class ch.aplu.nxt.I2CSensor |
---|
getData, getLejosI2CSensor, getLejosPort, getProductID, getVersion, sendData, sendData |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UltrasonicSensor(SensorPort port)
port
- the port where the sensor is plugged-inpublic UltrasonicSensor()
Method Detail |
---|
public void addUltrasonicListener(UltrasonicListener ultrasonicListener, int triggerLevel)
ultrasonicListener
- the UltrasonicListener to become registered.triggerLevel
- the trigger level where the callback is triggeredpublic void addUltrasonicListener(UltrasonicListener ultrasonicListener)
ultrasonicListener
- the UltrasonicListener to become registered.public int setTriggerLevel(int triggerLevel)
triggerLevel
- the new trigger level
public int getDistance()
public lejos.nxt.UltrasonicSensor getLejosSensor()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |