de.wagner_ibw.iow.i2c
Class DS1803

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

public class DS1803
extends AbstractI2CDevice

Implemenation of the DS1803 device, "Two independently controlled Potentiometers". Each patentiometer's wiper can be set to one of 256 positions.

Standard resistance values:

Since:
0.9.5.
Author:
Thomas Wagner

Field Summary
static int CLASS
          Group 1 part of slave address for PCF8570 (PCF8570 device specific constant).
static int CMD_BOTH_POTS
          Command "Write Both Pots".
static int CMD_POT_0
          Command "Write Pot 0".
static int CMD_POT_1
          Command "Write Pot 1".
 int MAX_POSITION_VALUE
          Maximum position value.
static java.lang.String NAME
          PCF8570 device specific constants.
 
Fields inherited from class de.wagner_ibw.iow.i2c.AbstractI2CDevice
MAX_I2C_LENGTH
 
Constructor Summary
DS1803(int deviceAddress)
          Constructor
 
Method Summary
 boolean equals(java.lang.Object o)
          Indicates whether some other DS1803 object is "equal to" this one.
 int hashCode()
          Returns a hash code value for this DS1803 object.
 int readPot0()
          Reads the pot 0 position.
 int readPot1()
          Reads the pot 1 position.
 void setIowDevice(AbstractIowDevice iow)
          Sets the reference to an IO-Warrior device for write report operations.
 java.lang.String toString()
          Returns Information about this DS1803 as String.
 void writeBothPots(int position)
          Sets the both pots position (same value).
 void writeBothPots(int position0, int position1)
          Sets the both pots position (different value).
 void writePot0(int position)
          Sets the pot 0 position.
 void writePot1(int position)
          Sets the pot 1 position.
 
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
PCF8570 device specific constants.

See Also:
Constant Field Values

MAX_POSITION_VALUE

public final int MAX_POSITION_VALUE
Maximum position value.

See Also:
Constant Field Values

CMD_POT_0

public static final int CMD_POT_0
Command "Write Pot 0".

See Also:
Constant Field Values

CMD_POT_1

public static final int CMD_POT_1
Command "Write Pot 1".

See Also:
Constant Field Values

CMD_BOTH_POTS

public static final int CMD_BOTH_POTS
Command "Write Both Pots".

See Also:
Constant Field Values

CLASS

public static final int CLASS
Group 1 part of slave address for PCF8570 (PCF8570 device specific constant).

See Also:
Constant Field Values
Constructor Detail

DS1803

public DS1803(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

readPot0

public int readPot0()
             throws java.lang.Exception
Reads the pot 0 position.

Returns:
pot 0 position (0...255)
Throws:
java.lang.Exception - If any transmission error occurred.

readPot1

public int readPot1()
             throws java.lang.Exception
Reads the pot 1 position.

Returns:
pot 1 position (0...255)
Throws:
java.lang.Exception - If any transmission error occurred.

writePot0

public void writePot0(int position)
               throws java.lang.Exception,
                      java.lang.IllegalArgumentException
Sets the pot 0 position.

Parameters:
position -
Throws:
java.lang.Exception - If any transmission error occurred.
java.lang.IllegalArgumentException - if the position value is out of range

writePot1

public void writePot1(int position)
               throws java.lang.Exception,
                      java.lang.IllegalArgumentException
Sets the pot 1 position.

Parameters:
position -
Throws:
java.lang.Exception - If any transmission error occurred.
java.lang.IllegalArgumentException - if the position value is out of range

writeBothPots

public void writeBothPots(int position)
                   throws java.lang.Exception,
                          java.lang.IllegalArgumentException
Sets the both pots position (same value).

Parameters:
position -
Throws:
java.lang.Exception - If any transmission error occurred.
java.lang.IllegalArgumentException - if the position value is out of range

writeBothPots

public void writeBothPots(int position0,
                          int position1)
                   throws java.lang.Exception,
                          java.lang.IllegalArgumentException
Sets the both pots position (different value).

Throws:
java.lang.Exception - If any transmission error occurred.
java.lang.IllegalArgumentException - if the position value is out of range

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 DS1803 as String.

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

equals

public boolean equals(java.lang.Object o)
Indicates whether some other DS1803 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 DS1803 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.