|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlejos.nxt.I2CSensor
lejos.nxt.UltrasonicSensor
public class UltrasonicSensor
Abstraction for a NXT Ultrasonic Sensor.
WARNING: THIS CLASS IS SHARED BETWEEN THE classes AND pccomms PROJECTS.
DO NOT EDIT THE VERSION IN pccomms AS IT WILL BE OVERWRITTEN WHEN THE PROJECT IS BUILT.
| Field Summary |
|---|
| Fields inherited from interface lejos.nxt.SensorConstants |
|---|
MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, TYPE_ANGLE, TYPE_CUSTOM, 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 |
| Constructor Summary | |
|---|---|
UltrasonicSensor(I2CPort port)
|
|
| Method Summary | |
|---|---|
int |
capture()
Set capture mode Set the sensor into capture mode. |
int |
continuous()
Switch to continuous ping mode. |
int |
getCalibrationData(byte[] data)
Return 3 bytes of calibration data. |
byte |
getContinuousInterval()
Return the interval used in continuous mode. |
int |
getData(int register,
byte[] buf,
int len)
Executes an I2C read transaction and waits for the result. |
int |
getDistance()
Return distance to an object. |
int |
getDistances(int[] dist)
Return an array of 8 echo distances. |
int |
getFactoryData(byte[] data)
Return 10 bytes of factory calibration data. |
byte |
getMode()
Returns the current operating mode of the sensor. |
String |
getUnits()
Return a string indicating the type of units in use by the unit. |
int |
off()
Turn off the sensor. |
int |
ping()
Send a single ping. |
int |
reset()
Reset the device Performs a "soft reset" of the device. |
int |
sendData(int register,
byte[] buf,
int len)
Executes an I2C write transaction. |
int |
setCalibrationData(byte[] data)
Set 3 bytes of calibration data. |
int |
setContinuousInterval(byte interval)
Set the ping inetrval used when in continuous mode. |
| Methods inherited from class lejos.nxt.I2CSensor |
|---|
fetchString, getPort, getProductID, getSensorType, getVersion, sendData, setAddress |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public UltrasonicSensor(I2CPort port)
| Method Detail |
|---|
public int getData(int register,
byte[] buf,
int len)
I2CSensor
getData in class I2CSensorregister - I2C register, e.g 0x41buf - Buffer to return datalen - Length of the return data
public int sendData(int register,
byte[] buf,
int len)
I2CSensor
sendData in class I2CSensorregister - I2C register, e.g 0x42buf - Buffer containing data to sendlen - Length of data to send
public int getDistance()
public int getDistances(int[] dist)
public int ping()
public int continuous()
public int off()
public int capture()
public int reset()
public int getFactoryData(byte[] data)
public String getUnits()
public int getCalibrationData(byte[] data)
public int setCalibrationData(byte[] data)
public byte getContinuousInterval()
public int setContinuousInterval(byte interval)
public byte getMode()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||