de.wagner_ibw.iow.i2c
Class PCF8591

java.lang.Object
  |
  +--de.wagner_ibw.iow.i2c.AbstractI2CDevice
        |
        +--de.wagner_ibw.iow.i2c.PCF8591
All Implemented Interfaces:
I2CDevice

public class PCF8591
extends AbstractI2CDevice

This is the implementation of the PCF8591 device, "8-bit A/D and D/A converter".

Since:
0.9.5
Author:
Thomas Wagner

Field Summary
static int ANALOGUE_OUTPUT_ENABLE
          Constant for 'Analogue Output Enable Flag' (analogue output active if 1).
static int AUTOINCREMENT
          Constant for 'Autoincrement Flag' (switched on if 1).
static int CLASS
          Group 1 part of slave address for PCF8591
static int INPUT_MODE_0
          Constant for 'Analogue Input Programming': Four single ended inputs.
static int INPUT_MODE_1
          Constant for 'Analogue Input Programming': Three differential inputs.
static int INPUT_MODE_2
          Constant for 'Analogue Input Programming': Single ended and differential mixed.
static int INPUT_MODE_3
          Constant for 'Analogue Input Programming': Two differential inputs.
static java.lang.String NAME
          PCF8591 device specific constants.
 
Fields inherited from class de.wagner_ibw.iow.i2c.AbstractI2CDevice
MAX_I2C_LENGTH
 
Constructor Summary
PCF8591(int deviceAddress)
          Constructor.
 
Method Summary
 void disableAnalogueOutput()
           
 void enableAnalogueOutput()
           
 boolean equals(java.lang.Object o)
          Indicates whether some other PCF8591 object is "equal to" this one.
 int getChannel(int channel)
          Returns the value of the desired A/D channel.
 int[] getChannels()
          Returns the values of all A/D channels.
 int hashCode()
          Returns a hash code value for this PCF8591 object.
 void setAnalogueInputProgramming(int mode)
           
 void setAnalogueOutputValue(int value)
           
 void setIowDevice(AbstractIowDevice iow)
          Sets the reference to an IO-Warrior device for write report operations.
 java.lang.String toString()
          Returns Information about this PCF8591 as String.
 
Methods inherited from class de.wagner_ibw.iow.i2c.AbstractI2CDevice
getI2cAddress, getName, readI2C, reportReceived, setMonitor, writeI2C
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
PCF8591 device specific constants.

See Also:
Constant Field Values

CLASS

public static final int CLASS
Group 1 part of slave address for PCF8591

See Also:
Constant Field Values

AUTOINCREMENT

public static final int AUTOINCREMENT
Constant for 'Autoincrement Flag' (switched on if 1).

See Also:
Constant Field Values

ANALOGUE_OUTPUT_ENABLE

public static final int ANALOGUE_OUTPUT_ENABLE
Constant for 'Analogue Output Enable Flag' (analogue output active if 1).

See Also:
Constant Field Values

INPUT_MODE_0

public static final int INPUT_MODE_0
Constant for 'Analogue Input Programming': Four single ended inputs.

See Also:
Constant Field Values

INPUT_MODE_1

public static final int INPUT_MODE_1
Constant for 'Analogue Input Programming': Three differential inputs.

See Also:
Constant Field Values

INPUT_MODE_2

public static final int INPUT_MODE_2
Constant for 'Analogue Input Programming': Single ended and differential mixed.

See Also:
Constant Field Values

INPUT_MODE_3

public static final int INPUT_MODE_3
Constant for 'Analogue Input Programming': Two differential inputs.

See Also:
Constant Field Values
Constructor Detail

PCF8591

public PCF8591(int deviceAddress)
        throws java.lang.Exception
Constructor.

Parameters:
deviceAddress - Group 2 part of slave address (possible values 0...7).
Throws:
java.lang.Exception - If anything goes wrong.
Method Detail

setAnalogueInputProgramming

public void setAnalogueInputProgramming(int mode)
                                 throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException

getChannel

public int getChannel(int channel)
               throws java.lang.Exception,
                      java.lang.IllegalArgumentException
Returns the value of the desired A/D channel.

Parameters:
channel -
Returns:
channel value
Throws:
java.lang.Exception
java.lang.IllegalArgumentException

getChannels

public int[] getChannels()
                  throws java.lang.Exception,
                         java.lang.IllegalArgumentException
Returns the values of all A/D channels.

Returns:
channel value
Throws:
java.lang.Exception
java.lang.IllegalArgumentException

enableAnalogueOutput

public void enableAnalogueOutput()

disableAnalogueOutput

public void disableAnalogueOutput()

setAnalogueOutputValue

public void setAnalogueOutputValue(int value)
                            throws java.lang.Exception,
                                   java.lang.IllegalArgumentException
Parameters:
value -
java.lang.Exception
java.lang.IllegalArgumentException

setIowDevice

public void setIowDevice(AbstractIowDevice iow)
Description copied from interface: I2CDevice
Sets the reference to an IO-Warrior device for write report operations.

Specified by:
setIowDevice in interface I2CDevice
Specified by:
setIowDevice in class AbstractI2CDevice
Parameters:
iow - Instance of an IO-Warrior device.

toString

public java.lang.String toString()
Returns Information about this PCF8591 as String.

Overrides:
toString in class AbstractI2CDevice
Returns:
String representation of information about this PCF8591. (slave address, temperatures, ...).

equals

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

Overrides:
equals in class AbstractI2CDevice
Returns:
True if this object is the same as the obj argument; false otherwise.

hashCode

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

Overrides:
hashCode in class AbstractI2CDevice
Returns:
a hash code value for this object.