import java.io.IOException;
import jcontrol.comm.I2C;

/**
 * <p>LM75 is a class to access the I2C-compatible
 * temperature sensor LM75 from National Semiconductor.</p>
 *
 * <p>(C) DOMOLOGIC Home Automation GmbH 2003-2005</p>
 */
public class LM75 extends I2C{

	/**
	 *	Constructor of this class.
	 *
	 *  @param address slave address of the device
	 */
    public LM75(int address){
    	super(address);
    }

    /**
     *	Returns an Integer value representing the
     *  current die temperatur of the LM75.
     *
     *  @returns An integer representing the current
     *           temperature in "Centigrades" (10*degree Celsius).
     */
    public int getTemp() throws IOException {
        // allocate buffer for temperature
        byte[] buf = new byte[2];
        // read content of 16-bit register #0x00
        read(new byte[] {0x00}, buf, 0, 2);
        // return integer value
        return (buf[0]*10) + (((buf[1] & 0x80) >> 7)*5);
    }
}

