Package comm
Class I2C

Public Method write

void write(byte value)

Throws:

void write(byte[] buf)

Throws:

void write(byte[] buf, byte register)

Throws:

void write(byte[] buf, byte register, int offset, int len)

Throws:

void write(byte[] buf, int offset, int len)

Throws:

void write(byte[] buf, short register)

Throws:

void write(byte[] buf, short register, int offset, int len)

Throws:

_INSERT_METHOD_SIGNATURE_HERE_

Description:

write(byte value) method:

Parameter Description
value data byte that should be sent

The parameter value is a single byte which should be transmitted to the slave device.

write(byte[] buf) method:

Parameter Description
buf data bytes that should be sent

The parameter buf represents an array of bytes which should be transmitted to a specific slave device.

write(byte[] buf, byte register) method:

Parameter Description
buf data bytes that should be sent
register an extra byte is sent to the slave

The parameter buf represents an array of bytes which should be transmitted to a specific slave device. Additionally, one extra byte is transmitted directly after the address byte. This is typically used to specify a slave device register where buf is to be written to.

write(byte[] buf, byte register, int offset, int len) method:

Parameter Description
buf data bytes that should be sent
register an extra byte is sent to the slave
offset offset in buf array
len number of the data bytes to be written

The parameter buf represents an array of bytes which should be transmitted to a specific slave device. Additionally, one extra byte is transmitted directly after the address byte. This is typically used to specify a slave device register where buf is to be written to. The number of data bytes must be specified by the len parameter. The offset paramter specifies the offset in the buf array.

write(byte[] buf, int offset, int len) method:

Parameter Description
buf data bytes that should be sent
offset offset in buf array
len number of the data byte

The parameter buf represents an array of bytes which should be transmitted to a specific slave device. The number of data bytes must be specified by the len parameter. The offset paramter specifies the offset in the buf array.

write(byte[] buf, short register) method:

Parameter Description
buf data bytes that should be sent
register two extra bytes are sent to the slave

The parameter buf represents an array of bytes which should be transmitted to a specific slave device. Additionally, two extra bytes are transmitted directly after the address byte. This is typically used to specify a slave device register where buf is to be written to.

write(byte[] buf, short register, int offset, int len) method:

Parameter Description
buf data bytes that should be sent
register two extra bytes are sent to the slave
offset offset to the first data byte
len number of the data byte

The parameter buf represents an array of bytes which should be transmitted to a specific slave device. Additionally, two extra bytes are transmitted directly after the address byte. This is typically used to specify a slave device register where buf is to be written to. The number of data bytes must be specified by the len parameter. The offset paramter specifies the offset in the buf array.

Note


Example

The following example excludes the start() and stop() method calls which are required for an I2C communication.

  byte[] data = {0x30, 0x40};
  byte register = SI7021_READRHT_REG_CMD;
   
  try
  {      
     i2c.start();
     i2c.write(data, register, offset, length);
     i2c.stop();
  }
  catch(Exception exc)
  {
     Console.println(exc.getMessage());
  }      

The code above writes one extra byte to a specific slave device register after the address byte is sent. Afterwards two bytes are written to the same slave.

See also:

SPI
UART