de.wagner_ibw.iow.i2c
Class I2CAddress

java.lang.Object
  |
  +--de.wagner_ibw.iow.i2c.I2CAddress

public class I2CAddress
extends java.lang.Object

This class represents an i2c slave address. It contains the group 1 part (4 bit long, further called 'device class') and the group 2 part (3 bit long, further called device address) of the slave address.

Author:
Thomas Wagner

Constructor Summary
I2CAddress(int deviceClass, int deviceAddress)
          Creates an new I2CAddress.
 
Method Summary
 boolean equals(java.lang.Object o)
          Indicates whether some other I2CAddress object is "equal to" this one.
 int getDeviceAddress()
          Returns the device address.
 int getDeviceClass()
          Returns the device class.
 int getReadAddress()
          Returns the slave address for read operations (bit 0 is set).
 int getWriteAddress()
          Returns the slave address for write operations (bit 0 is clear).
 int hashCode()
          Returns a hash code value for this I2CAddress object.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

I2CAddress

public I2CAddress(int deviceClass,
                  int deviceAddress)
           throws java.lang.IllegalArgumentException
Creates an new I2CAddress.

Parameters:
deviceClass - Group 1 part (device class) of the i2c slave address.
deviceAddress - Group 2 part (device address) of the i2c slave address.
Method Detail

getDeviceClass

public int getDeviceClass()
Returns the device class.

Returns:
Group 2 part of i2c slave address (bit 3...1).
Since:
0.9.4

getDeviceAddress

public int getDeviceAddress()
Returns the device address.

Returns:
Group 1 part of i2c slave address (bit 7...4).
Since:
0.9.4

getReadAddress

public int getReadAddress()
Returns the slave address for read operations (bit 0 is set).

Returns:
Read address.

getWriteAddress

public int getWriteAddress()
Returns the slave address for write operations (bit 0 is clear).

Returns:
Write address.

toString

public java.lang.String toString()
Returns a string representation of the object. It consists of the device class and device address information.

Overrides:
toString in class java.lang.Object
Returns:
a string consisting of the device class, the character '/' and the device address.

equals

public boolean equals(java.lang.Object o)
Indicates whether some other I2CAddress object is "equal to" this one. Criterias are the i2c device class and i2c device address.

Overrides:
equals in class java.lang.Object
Returns:
True if this object is the same as the obj argument; false otherwise.
Since:
0.9.4

hashCode

public int hashCode()
Returns a hash code value for this I2CAddress object. It is derived from the i2c device class and i2c device address.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.
Since:
0.9.4