cork.module.ti
Class PCF8574

java.lang.Object
  |
  +--cork.device.AbstractDevice
        |
        +--cork.net.i2c.AbstractI2CDevice
              |
              +--cork.module.ti.PCF8574
All Implemented Interfaces:
Device, I2CDevice

public class PCF8574
extends AbstractI2CDevice

Driver for controlling a Texas Instruments PCF8574 Remote 8-Bit I/O Expander chip.

The IO port can be controlled as an array of 8 boolean values, or as a byte value where the binary representation of a number between 0 and 255 sets the bits of the port. e.g. setting the byte to 0 (binary=00000000) will set all 8 physical buts to logic low, and setting the byte to 255 (binary=11111111) will set all 8 bits on teh physical device to logic high.

Version:
0.1.1
Author:
Brill Pappin

Field Summary
static int ADDRESS_56
          Description of the Field
static int ADDRESS_57
          Description of the Field
static int ADDRESS_58
          Description of the Field
static int ADDRESS_59
          Description of the Field
static int ADDRESS_60
          Description of the Field
static int ADDRESS_61
          Description of the Field
static int ADDRESS_62
          Description of the Field
static int ADDRESS_63
          Description of the Field
 
Constructor Summary
PCF8574(int address)
          Constructor for the PCF8574 object.
 
Method Summary
 void getBits(boolean[] buffer)
          Gets the bits of the PCF8574 object.
 int getByte()
          Gets the bits of the PCF8574 object.
 java.lang.String getDeviceDestription()
          Gets the deviceDestription attribute of the CMPS03 object
 java.lang.String getDeviceName()
          Gets the deviceName attribute of the CMPS03 object
 I2CDevice getI2CDevice()
          Gets this instance.
 void setBits(boolean[] bits)
          Sets the bits of the PCF8574 object.
 void setByte(int bits)
          Sets the bits of the PCF8574 object.
 
Methods inherited from class cork.net.i2c.AbstractI2CDevice
capture, destroy, getBusMaster, getDeviceAddress, isCaptured, read, release, start, stop, tick, write
 
Methods inherited from class cork.device.AbstractDevice
addEventListener, removeEventListener, sendDeviceEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADDRESS_56

public static final int ADDRESS_56
Description of the Field
Since:
 

ADDRESS_57

public static final int ADDRESS_57
Description of the Field
Since:
 

ADDRESS_58

public static final int ADDRESS_58
Description of the Field
Since:
 

ADDRESS_59

public static final int ADDRESS_59
Description of the Field
Since:
 

ADDRESS_60

public static final int ADDRESS_60
Description of the Field
Since:
 

ADDRESS_61

public static final int ADDRESS_61
Description of the Field
Since:
 

ADDRESS_62

public static final int ADDRESS_62
Description of the Field
Since:
 

ADDRESS_63

public static final int ADDRESS_63
Description of the Field
Since:
 
Constructor Detail

PCF8574

public PCF8574(int address)
Constructor for the PCF8574 object. Select the address from the constants in this class that correspond to the phyisical address set on your device. If no address is set, teh device will default to ADDRESS_56.
Parameters:
address - The address that the physical device has been pinstrapped to. The default if no pins are strapped is ADDRESS_56.
Since:
0.1.0
Method Detail

getBits

public void getBits(boolean[] buffer)
             throws I2CException
Gets the bits of the PCF8574 object. The boolean values correspond to P0-P7 on the physical device.
Parameters:
buffer - The buffer to put the bits into. The buffer should have a length of at least 8.
Throws:
I2CException - if the bits can not be returned for some reason.
Since:
0.1.0

getByte

public int getByte()
            throws I2CException
Gets the bits of the PCF8574 object.
Returns:
int all 8 bits as a byte
Throws:
I2CException - Description of Exception
Since:
0.1.1

getDeviceName

public java.lang.String getDeviceName()
Gets the deviceName attribute of the CMPS03 object
Returns:
The deviceName value
Since:
0.1.0

getDeviceDestription

public java.lang.String getDeviceDestription()
Gets the deviceDestription attribute of the CMPS03 object
Returns:
The deviceDestription value
Since:
0.1.0

getI2CDevice

public I2CDevice getI2CDevice()
Gets this instance.
Overrides:
getI2CDevice in class AbstractI2CDevice
Returns:
The i2CDevice value
Since:
0.1.0

setByte

public void setByte(int bits)
             throws I2CException
Sets the bits of the PCF8574 object.
Parameters:
bits - int all 8 bits as a byte.
Throws:
I2CException - if the bits can not be set for some reason.
Since:
0.1.1

setBits

public final void setBits(boolean[] bits)
                   throws I2CException
Sets the bits of the PCF8574 object. The boolean values correspond to P0-P7 on the physical device.
Parameters:
bits - a boolean array with a length of at least 8.
Throws:
I2CException - if the bits can not be set for some reason.
Since:
0.1.0