public interface I2CDevice
Modifier and Type | Method and Description |
---|---|
void |
ask(byte responseLength,
I2CListener listener)
Requests data from I2C device and receives it only once.
|
void |
ask(int register,
byte responseLength,
I2CListener listener)
Requests data from I2C device and receives it only once.
|
byte |
getAddress()
Returns address of I2C device.
|
void |
setDelay(int delay)
Sets delay between writing and reading data to/from I2C device.
|
void |
startReceivingUpdates(byte messageLength)
Tells I2C device to send data continuously as it available.
|
void |
stopReceivingUpdates()
Tells I2C device to stop sending data continuously.
|
void |
subscribe(I2CListener listener)
Registers a listener as a receiver of regular updates from I2C device.
|
void |
tell(byte... data)
Sends data to the I2C device.
|
void |
unsubscribe(I2CListener listener)
Unregisters a listener from receiving of regular updates from I2C device.
|
byte getAddress()
void setDelay(int delay) throws IOException
delay
- delay between the moment the device is written to and the
moment when the data can be read from itIOException
- when delay cannot be set due to communication failvoid tell(byte... data) throws IOException
data
- data to sendIOException
- when the data cannot be sent due to communication
failvoid ask(byte responseLength, I2CListener listener) throws IOException
responseLength
- length of expected responselistener
- processor of the responseIOException
- when I2C device cannot be asked for data due to
communication failvoid ask(int register, byte responseLength, I2CListener listener) throws IOException
register
- Device register to read from.responseLength
- length of expected responselistener
- processor of the responseIOException
- when I2C device cannot be asked for data due to
communication failvoid subscribe(I2CListener listener)
startReceivingUpdates(byte)
invocation.listener
- the object that receives updatesvoid unsubscribe(I2CListener listener)
listener
- the object that used to receive updatesvoid startReceivingUpdates(byte messageLength) throws IOException
messageLength
- length of expected messageIOException
- when I2C device cannot be asked for data due to
communication failvoid stopReceivingUpdates() throws IOException
IOException
- when I2C device cannot be asked to stop due to
communication failCopyright © 2017. All rights reserved.