|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object icommand.nxt.I2CSensor
public class I2CSensor
A sensor wrapper to allow easy access to I2C sensors, like the ultrasonic sensor. Currently uses the default I2C address of 0x02, but some sensors can be connected to same port lines and use different addresses using the Auto Detecting Parallel Architecture (ADPA). Currently unsure if there are commercial port expanders yet to use this function, or whether the Lego UltrasonicSensor sensor is ADPA compatible.
Field Summary | |
---|---|
protected static byte |
DEFAULT_ADDRESS
|
protected static byte |
PRODUCT_ID
Returns the product ID of the sensor. |
protected static byte |
SENSOR_TYPE
Returns the sensor type. |
protected static byte |
STOP
|
protected static byte |
VERSION
Returns the version number of the sensor. |
Constructor Summary | |
---|---|
I2CSensor(SensorPort s,
byte sensorType)
|
Method Summary | |
---|---|
protected java.lang.String |
fetchString(byte constantEnumeration,
int rxLength)
Helper method for retrieving string cosntants using I2C protocol. |
protected byte |
getData(byte register)
Helper method to return a single register byte. |
protected byte[] |
getData(byte register,
int length)
Method for retrieving data values from the sensor. |
int |
getId()
|
java.lang.String |
getProductID()
Returns the Product ID as a string. |
java.lang.String |
getSensorType()
Returns the type of sensor as a string. |
java.lang.String |
getVersion()
Returns the version number of the sensor hardware. |
protected void |
sendData(byte register,
byte value)
Sets a single byte in the I2C sensor. |
protected void |
sendData(byte register,
byte value1,
byte value2)
EXPERIMENTAL for RCXLink. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static byte DEFAULT_ADDRESS
protected static byte STOP
protected static byte VERSION
protected static byte PRODUCT_ID
protected static byte SENSOR_TYPE
Constructor Detail |
---|
public I2CSensor(SensorPort s, byte sensorType)
s
- A sensor. e.g. Port.S1Method Detail |
---|
public int getId()
protected byte[] getData(byte register, int length)
register
- e.g. FACTORY_SCALE_DIVISOR, BYTE0, etc....length
- Length of data to read (minimum 1, maximum 16)
protected byte getData(byte register)
register
-
protected void sendData(byte register, byte value)
register
- A data register in the I2C sensor. e.g. ACTUAL_ZEROvalue
- The data value.protected void sendData(byte register, byte value1, byte value2)
register
- A data register in the I2C sensor. e.g. ACTUAL_ZEROvalue
- The data value.public java.lang.String getVersion()
public java.lang.String getProductID()
public java.lang.String getSensorType()
protected java.lang.String fetchString(byte constantEnumeration, int rxLength)
constantEnumeration
- e.g. I2CProtocol.VERSION
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |