de.wagner_ibw.iow.i2c
Class LM75

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

public class LM75
extends AbstractI2CDevice

This is the implemenation of the LM75 device , "Digital Temperature Sensor and Thermal Watchdog with Two-Wire Interface", by National Semiconductors.

This class almost supports features of the device:

Unsupported features are:

Author:
Thomas Wagner

Nested Class Summary
private  class LM75.LM75Temp
          Inner class for LM75 temperature representation.
 
Field Summary
static int CLASS
          Group 1 part of slave address for LM75 (LM75 device specific constant).
private  int lastRegisterPointer
          Flag for last register access.
private  int mode
          Current mode (initialized with factory default value, read from LM75).
static int MODE_COMPARATOR
          Constant for 'Comparator' mode.
static int MODE_INTERRUPT
          Constant for 'Interrupt' mode.
static java.lang.String NAME
          PCF8570 device specific constants.
private  int polarity
          Current polarity (initialized with factory default value, read from LM75).
static int POLARITY_ACTIVE_HIGH
          Constant for O.S. output polarity 'active high'.
static int POLARITY_ACTIVE_LOW
          Constant for O.S. output polarity 'active low'.
static int REG_CONFIG
          Constant for register pointer for 'Configuration' register (LM75 device specific constant).
static int REG_TEMP
          Constant for register pointer for 'Temperature' register (LM75 device specific constant).
static int REG_TEMP_HYST
          Constant for register pointer for 'THyst Set Point' register (LM75 device specific constant).
static int REG_TEMP_OS
          Constant for register pointer for 'TOS Set Point' register (LM75 device specific constant).
private  double tCurrent
          Current temperature (measured by LM75).
private  double tHyst
          Current setted THYST temperature (initialized with factory default value).
private  double tOs
          Current setted OS temperature (initialized with factory default value).
 
Fields inherited from class de.wagner_ibw.iow.i2c.AbstractI2CDevice
devAdr, iow, MAX_I2C_LENGTH, monitor, readQueue, writeAckQueue
 
Constructor Summary
LM75(int deviceAddress)
          Constructor
 
Method Summary
 boolean equals(java.lang.Object o)
          Indicates whether some other LM75 object is "equal to" this one.
 void getConfiguration()
           
 int getMode()
          Getter for mode of this LM75 device.
 int getPolarity()
          Getter for polarity of this LM75 device.
 double getT()
          Returns Current temperature measured by this LM75.
private  double getTemperature()
          Support method for getting temperature value for register.
 double getTHyst()
          Returns THYST set point stored in this LM75.
 double getTOs()
          Returns TOS set point stored in this LM75.
 int hashCode()
          Returns a hash code value for this LM75 object.
private  void init()
           
 void setConfiguration(int mode, int polarity)
           
 void setIowDevice(AbstractIowDevcie iow)
          Sets the reference to an iow device for write report operations.
private  void setRegister(int regAdr, int count, int firstByte, int secondByte)
          Support method for setting writeable registers.
private  void setRegisterPointer(int pointer)
          Support method for setting register pointer.
 void setTHyst(double value)
          Sets THYST set point in this LM75.
 void setTOs(double value)
          Sets TOS set point in this LM75.
 java.lang.String toString()
          Returns Information about this LM75 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
clone, finalize, 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

CLASS

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

See Also:
Constant Field Values

REG_TEMP

public static final int REG_TEMP
Constant for register pointer for 'Temperature' register (LM75 device specific constant).

See Also:
Constant Field Values

REG_CONFIG

public static final int REG_CONFIG
Constant for register pointer for 'Configuration' register (LM75 device specific constant).

See Also:
Constant Field Values

REG_TEMP_HYST

public static final int REG_TEMP_HYST
Constant for register pointer for 'THyst Set Point' register (LM75 device specific constant).

See Also:
Constant Field Values

REG_TEMP_OS

public static final int REG_TEMP_OS
Constant for register pointer for 'TOS Set Point' register (LM75 device specific constant).

See Also:
Constant Field Values

MODE_COMPARATOR

public static final int MODE_COMPARATOR
Constant for 'Comparator' mode.

See Also:
Constant Field Values

MODE_INTERRUPT

public static final int MODE_INTERRUPT
Constant for 'Interrupt' mode.

See Also:
Constant Field Values

POLARITY_ACTIVE_LOW

public static final int POLARITY_ACTIVE_LOW
Constant for O.S. output polarity 'active low'.

See Also:
Constant Field Values

POLARITY_ACTIVE_HIGH

public static final int POLARITY_ACTIVE_HIGH
Constant for O.S. output polarity 'active high'.

See Also:
Constant Field Values

tOs

private double tOs
Current setted OS temperature (initialized with factory default value).


tHyst

private double tHyst
Current setted THYST temperature (initialized with factory default value).


tCurrent

private double tCurrent
Current temperature (measured by LM75).


mode

private int mode
Current mode (initialized with factory default value, read from LM75).


polarity

private int polarity
Current polarity (initialized with factory default value, read from LM75).


lastRegisterPointer

private int lastRegisterPointer
Flag for last register access.

Constructor Detail

LM75

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

init

private void init()
           throws java.lang.Exception
java.lang.Exception

getT

public double getT()
            throws java.lang.Exception
Returns Current temperature measured by this LM75.

Returns:
Temperature as double value from this LM75.
Throws:
java.lang.Exception - If anything goes wrong.

getConfiguration

public void getConfiguration()
                      throws java.lang.Exception
java.lang.Exception

getTHyst

public double getTHyst()
                throws java.lang.Exception
Returns THYST set point stored in this LM75.

Returns:
HYST temperature as double value from this LM75.
Throws:
java.lang.Exception - If anything goes wrong.

getTOs

public double getTOs()
              throws java.lang.Exception
Returns TOS set point stored in this LM75.

Returns:
OS temperature as double value from this LM75.
Throws:
java.lang.Exception - If anything goes wrong.

setConfiguration

public void setConfiguration(int mode,
                             int polarity)
                      throws java.lang.Exception
java.lang.Exception

setTHyst

public void setTHyst(double value)
              throws java.lang.Exception
Sets THYST set point in this LM75.

Parameters:
value - Desired HYST temperature as doubel value.
java.lang.Exception

setTOs

public void setTOs(double value)
            throws java.lang.Exception
Sets TOS set point in this LM75.

Parameters:
value - Desired OS temperature as doubel value.
java.lang.Exception

getMode

public int getMode()
Getter for mode of this LM75 device.

Returns:
Mode of this I2C device.

getPolarity

public int getPolarity()
Getter for polarity of this LM75 device.

Returns:
Polarity of this I2C device.

setRegisterPointer

private void setRegisterPointer(int pointer)
                         throws java.lang.Exception
Support method for setting register pointer.

Parameters:
pointer - Desired register (possible values: REG_TEMP (0), REG_CONFIG (1), REG_TEMP_HYST (2), REG_TEMP_OS (3)).
Throws:
java.lang.Exception - If anything goes wrong.

getTemperature

private double getTemperature()
                       throws java.lang.Exception
Support method for getting temperature value for register. specified by preseted register pointer.

Returns:
Temperature as double value.
Throws:
java.lang.Exception - If anything goes wrong.

setRegister

private void setRegister(int regAdr,
                         int count,
                         int firstByte,
                         int secondByte)
                  throws java.lang.Exception
Support method for setting writeable registers. Possibly registers are CONFIG, TOS and THYST.

Parameters:
regAdr - Desired register (possible values: REG_CONFIG (1), REG_TEMP_HYST (2), REG_TEMP_OS (3)).
count - Counter of bytes of pay load (possible values: 1 or 2).
firstByte - First byte of the pay load (must set).
secondByte - Second byte of the pay load (if counter is 1 this param must be set 0).
Throws:
java.lang.Exception - If anything goes wrong.

setIowDevice

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

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

toString

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

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

equals

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

hashCode

public int hashCode()
Returns a hash code value for this LM75 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.
Since:
0.9.4