public class NxtUltrasonicSensor extends Sensor
Constructor and Description |
---|
NxtUltrasonicSensor()
Creates a sensor instance connected to port S1.
|
NxtUltrasonicSensor(SensorPort port)
Creates a sensor instance connected to the given port.
|
Modifier and Type | Method and Description |
---|---|
void |
addLightListener(UltrasonicListener ultrasonicListener)
Registers the given ultrasonic listener with default trigger level 500.
|
void |
addLightListener(UltrasonicListener ultrasonicListener,
int triggerLevel)
Registers the given ultrasonic listener for the given trigger level.
|
void |
eraseBeamArea()
Erases the beam area (if it is currently shown).
|
int |
getDistance()
Polls the sensor.
|
void |
setBeamAreaColor(java.awt.Color color)
Sets the color of the beam area (two sector border lines and axis).
|
void |
setMeshTriangleColor(java.awt.Color color)
Sets the color of the triangle mesh lines.
|
void |
setProximityCircleColor(java.awt.Color color)
Sets the color of the circle with center at sensor location and radius
equals to the current distance value.
|
int |
setTriggerLevel(int triggerLevel)
Sets a new trigger level and returns the previous one.
|
public NxtUltrasonicSensor(SensorPort port)
port
- the port where the sensor is plugged-inpublic NxtUltrasonicSensor()
public void addLightListener(UltrasonicListener ultrasonicListener, int triggerLevel)
ultrasonicListener
- the UltrasonicListener to become registered.triggerLevel
- the trigger level where the callback is triggeredpublic void addLightListener(UltrasonicListener ultrasonicListener)
ultrasonicListener
- the UltrasonicListener to become registered.public int setTriggerLevel(int triggerLevel)
triggerLevel
- the new trigger levelpublic int getDistance()
public void setMeshTriangleColor(java.awt.Color color)
color
- the color of the meshpublic void setBeamAreaColor(java.awt.Color color)
color
- the color of the beam areapublic void eraseBeamArea()
public void setProximityCircleColor(java.awt.Color color)
color
- the color of the circle