public class UltrasonicSensor extends Sensor
| Constructor and Description | 
|---|
UltrasonicSensor()
Creates a sensor instance connected to port S1. 
 | 
UltrasonicSensor(SensorPort port)
Creates a sensor instance connected to the given port. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addUltrasonicListener(UltrasonicListener ultrasonicListener)
Registers the given ultrasonic listener with default trigger level 10. 
 | 
void | 
addUltrasonicListener(UltrasonicListener ultrasonicListener,
                     int triggerLevel)
Registers the given ultrasonic listener for the given trigger level. 
 | 
int | 
getDistance()
Polls the sensor. 
 | 
lejos.hardware.sensor.EV3UltrasonicSensor | 
getLejosSensor()
Returns the reference of the the underlying lejos.hardware.sensor.EV3UltrasonicSensor. 
 | 
int | 
setTriggerLevel(int triggerLevel)
Sets a new trigger level and returns the previous one. 
 | 
getLejosPortpublic UltrasonicSensor(SensorPort port)
port - the port where the sensor is plugged-inpublic UltrasonicSensor()
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 levelpublic int getDistance()
public lejos.hardware.sensor.EV3UltrasonicSensor getLejosSensor()