- All Superinterfaces:
AutoCloseable,Describable,I2CRegisterDataReader,I2CRegisterDataReaderWriter,I2CRegisterDataWriter,Identity,IO<I2C,,I2CConfig, I2CProvider> IODataReader,IODataWriter,Lifecycle,Readable
- All Known Implementing Classes:
I2CBase
public interface I2C
extends IO<I2C,I2CConfig,I2CProvider>, IODataWriter, IODataReader, I2CRegisterDataReaderWriter, AutoCloseable
I2C I/O Interface for Pi4J I2C Bus/Device Communications
- Version:
- $Id: $Id
- Author:
- Robert Savage
Based on previous contributions from: Daniel Sendula, RasPelikan
-
Method Summary
Modifier and TypeMethodDescriptiondefault intbus()I2C Bus Addressvoidclose()close.default intdevice()I2C Device Address<T> TExecutes the given runnable on the I2C bus, locking the bus for the duration of the given taskdefault intgetBus()I2C Bus Addressdefault intI2C Device AddressgetRegister(int address) Get an encapsulated interface for reading and writing to a specific I2C device registerbooleanisOpen()I2C Device Communication State is OPENstatic I2CConfigBuildernewConfigBuilder(Context context) newConfigBuilder.default I2CRegisterregister(int address) I2C Device Register Get an encapsulated interface for reading and writing to a specific I2C device registerdefault intwriteRead(byte[] writeBuffer, byte[] readBuffer) Method to perform a write of the given buffer, and then a read into the given bufferdefault intwriteRead(byte[] writeBuffer, int writeSize, int writeOffset, byte[] readBuffer, int readSize, int readOffset) Method to perform a write of the given buffer, and then a read into the given bufferMethods inherited from interface com.pi4j.io.i2c.I2CRegisterDataReader
readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegister, readRegisterByte, readRegisterByteBuffer, readRegisterByteBuffer, readRegisterCharArray, readRegisterCharArray, readRegisterCharArray, readRegisterCharArray, readRegisterCharBuffer, readRegisterCharBuffer, readRegisterCharBuffer, readRegisterCharBuffer, readRegisterNBytes, readRegisterNBytes, readRegisterString, readRegisterString, readRegisterString, readRegisterString, readRegisterWordMethods inherited from interface com.pi4j.io.i2c.I2CRegisterDataReaderWriter
writeReadRegisterWordMethods inherited from interface com.pi4j.io.i2c.I2CRegisterDataWriter
write, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegister, writeRegisterWordMethods inherited from interface com.pi4j.common.Identity
describe, description, getDescription, getId, getMetadata, getName, id, metadata, nameMethods inherited from interface com.pi4j.io.IODataReader
getInputStream, in, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, readByte, readByteBuffer, readByteBuffer, readCharArray, readCharArray, readCharArray, readCharArray, readCharBuffer, readCharBuffer, readCharBuffer, readCharBuffer, readNBytes, readNBytes, readString, readString, readString, readStringMethods inherited from interface com.pi4j.io.IODataWriter
getOutputStream, out, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, writeMethods inherited from interface com.pi4j.common.Lifecycle
initialize, shutdown
-
Method Details
-
close
void close()close.
- Specified by:
closein interfaceAutoCloseable
-
newConfigBuilder
newConfigBuilder.
- Parameters:
context-Context- Returns:
- a
I2CConfigBuilderobject.
-
device
default int device()I2C Device Address- Returns:
- The I2C device address for which this instance is constructed for.
-
bus
default int bus()I2C Bus Address- Returns:
- The I2C bus address for which this instance is constructed for.
-
isOpen
boolean isOpen()I2C Device Communication State is OPEN- Returns:
- The I2C device communication state
-
getBus
default int getBus()I2C Bus Address- Returns:
- The I2C bus address for which this instance is constructed for.
-
getDevice
default int getDevice()I2C Device Address- Returns:
- The I2C device address for which this instance is constructed for.
-
writeRead
default int writeRead(byte[] writeBuffer, byte[] readBuffer) Method to perform a write of the given buffer, and then a read into the given buffer- Parameters:
writeBuffer- the buffer to writereadBuffer- the buffer to read into- Returns:
- the number of bytes read
-
writeRead
default int writeRead(byte[] writeBuffer, int writeSize, int writeOffset, byte[] readBuffer, int readSize, int readOffset) Method to perform a write of the given buffer, and then a read into the given buffer- Parameters:
writeBuffer- the buffer to write respecting the given length and offsetwriteSize- the number of bytes to writewriteOffset- the offset of the array to writereadBuffer- the buffer into which to read the bytesreadSize- the number of bytes to readreadOffset- the offset in the read buffer at which to insert the read bytes- Returns:
- the number of bytes read
-
getRegister
Get an encapsulated interface for reading and writing to a specific I2C device register- Parameters:
address- a int.- Returns:
- a
I2CRegisterobject.
-
register
I2C Device Register Get an encapsulated interface for reading and writing to a specific I2C device register- Parameters:
address- the (16-bit) device register address- Returns:
- an instance of I2CRegister for the provided register address
-
execute
Executes the given runnable on the I2C bus, locking the bus for the duration of the given task- Parameters:
action- the action to perform, returning a value
-