Package lejos.hardware.port
Interface I2CPort
-
- All Superinterfaces:
java.lang.AutoCloseable,BasicSensorPort,java.io.Closeable,IOPort,SensorConstants
- All Known Implementing Classes:
RemoteI2CPort,RemoteNXTI2CPort,RemoteRequestI2CPort
public interface I2CPort extends IOPort, BasicSensorPort
Abstraction for a port that supports I2C sensors.- Author:
- Lawrie Griffiths
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_IOMaximum read/write request length-
Fields inherited from interface lejos.hardware.sensor.SensorConstants
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidi2cTransaction(int deviceAddress, byte[] writeBuf, int writeOffset, int writeLen, byte[] readBuf, int readOffset, int readLen)High level i2c interface.-
Methods inherited from interface lejos.hardware.port.BasicSensorPort
getMode, getType, setMode, setType, setTypeAndMode
-
Methods inherited from interface lejos.hardware.port.IOPort
close, getName, setPinMode
-
-
-
-
Field Detail
-
MAX_IO
static final int MAX_IO
Maximum read/write request length- See Also:
- Constant Field Values
-
-
Method Detail
-
i2cTransaction
void i2cTransaction(int deviceAddress, byte[] writeBuf, int writeOffset, int writeLen, byte[] readBuf, int readOffset, int readLen)High level i2c interface. Perform a complete i2c transaction and return the results. Writes the specified data to the device and then reads the requested bytes from it.- Parameters:
deviceAddress- The I2C device address.writeBuf- The buffer containing data to be written to the device.writeOffset- The offset of the data within the write bufferwriteLen- The number of bytes to write.readBuf- The buffer to use for the transaction resultsreadOffset- Location to write the results toreadLen- The length of the read
-
-