public class NXTUltrasonicSensor extends I2CSensor
Supported modes | |||
---|---|---|---|
Mode name | Description | unit(s) | Getter |
Distance | Measures the distance to the nearest object in front of the sensor | meter | getDistanceMode() |
Ping | Measures the distance to the nearest 8 objects in front of the sensor | meter | getPingMode() |
See Mindstorms NXT HDK/SDK
See The
leJOS sensor framework
See leJOS conventions for
SampleProviders
Modifier and Type | Class and Description |
---|---|
class |
NXTUltrasonicSensor.DistanceMode |
class |
NXTUltrasonicSensor.PingMode |
Modifier and Type | Field and Description |
---|---|
protected static byte |
MODE_CONTINUOUS |
protected static byte |
MODE_OFF |
protected static byte |
MODE_PING |
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION, retryCount
modes
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, TYPE_HISPEED, 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, WHITE, YELLOW
Constructor and Description |
---|
NXTUltrasonicSensor(I2CPort port) |
NXTUltrasonicSensor(Port port) |
Modifier and Type | Method and Description |
---|---|
void |
disable() |
void |
enable() |
void |
getData(int register,
byte[] buf,
int off,
int len)
Executes an I2C read transaction and waits for the result.
|
SampleProvider |
getDistanceMode()
Gives a SampleProvider representing the sensor in distance mode.
|
SampleProvider |
getPingMode()
Gives a SampleProvider representing the sensor in ping mode.
|
boolean |
isEnabled() |
void |
sendData(int register,
byte[] buf,
int off,
int len)
Executes an I2C write transaction.
|
protected boolean |
setMode(byte mode)
Sets the sensor to CONTINUOUS, PING or OFF
|
fetchString, getAddress, getData, getPort, getProductID, getRetryCount, getVendorID, getVersion, sendData, sendData, setAddress, setRetryCount
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
close, releaseOnClose
protected static final byte MODE_OFF
protected static final byte MODE_PING
protected static final byte MODE_CONTINUOUS
public NXTUltrasonicSensor(I2CPort port)
public NXTUltrasonicSensor(Port port)
public void getData(int register, byte[] buf, int off, int len)
I2CSensor
public void sendData(int register, byte[] buf, int off, int len)
I2CSensor
public SampleProvider getDistanceMode()
public SampleProvider getPingMode()
public void enable()
public void disable()
public boolean isEnabled()
protected boolean setMode(byte mode)
mode
-