stamp.peripheral.sensor.temperature
Class TempSensor

java.lang.Object
  |
  +--stamp.peripheral.sensor.temperature.TempSensor
Direct Known Subclasses:
DS1620

public abstract class TempSensor
extends Object

TempSensor is an abstract class encapsulating the basic capabilities of a generic temperature sensor, including high and low threshold settings and simple (polled) alarms.


Field Summary
static int TEMP_HI
           
static int TEMP_LO
           
static int TEMP_OK
           
 
Constructor Summary
TempSensor()
           
 
Method Summary
 int CelsiusToFahr(int temp)
          Converts Celsius temperature to Fahrenheit
 int FahrToCelsius(int temp)
          Converts Fahrenheit temperature to Celsius
 int getTemp(char tmpUnits)
          Returns current temperature.
abstract  int getTempC()
           
abstract  int getTempF()
           
 int getTempHi(char tmpUnits)
          Returns high temperature threshold in specified units
 int getTempLo(char tmpUnits)
          Returns low temperature threshold in specified units
abstract  int getTempRaw()
           
 void setTempHi(int temp, char tmpUnits)
          Sets high temperature threshold
 void setTempLo(int temp, char tmpUnits)
          Sets low temperature threshold
 boolean tempHi()
          Returns high temperature alarm status.
 boolean tempLo()
          Returns low temperature alarm status.
 boolean tempOk()
          Returns temperature alarm status.
 int tempStatus()
          Returns sensor status: low, okay or high.
 
Methods inherited from class java.lang.Object
equals
 

Field Detail

TEMP_LO

public static final int TEMP_LO

TEMP_OK

public static final int TEMP_OK

TEMP_HI

public static final int TEMP_HI
Constructor Detail

TempSensor

public TempSensor()
Method Detail

getTempRaw

public abstract int getTempRaw()

getTempC

public abstract int getTempC()

getTempF

public abstract int getTempF()

getTemp

public int getTemp(char tmpUnits)
Returns current temperature.
Parameters:
tmpUnits - Temperature units (c, C, f or F)

FahrToCelsius

public int FahrToCelsius(int temp)
Converts Fahrenheit temperature to Celsius
Parameters:
temp - Fahrenheit temperature
Returns:
Celsius temperature

CelsiusToFahr

public int CelsiusToFahr(int temp)
Converts Celsius temperature to Fahrenheit
Parameters:
temp - Celsius temperature
Returns:
Celsius temperature

setTempLo

public void setTempLo(int temp,
                      char tmpUnits)
Sets low temperature threshold
Parameters:
temp - Low temperature threshold
tmpUnits - Temperature type (c, C, f or F)

setTempHi

public void setTempHi(int temp,
                      char tmpUnits)
Sets high temperature threshold
Parameters:
temp - High temperature threshold
tmpUnits - Temperature type (c, C, f or F)

getTempLo

public int getTempLo(char tmpUnits)
Returns low temperature threshold in specified units
Parameters:
tmpUnits - Temperature type (c, C, f or F)

getTempHi

public int getTempHi(char tmpUnits)
Returns high temperature threshold in specified units
Parameters:
tmpUnits - Temperature type (c, C, f or F)

tempLo

public boolean tempLo()
Returns low temperature alarm status.
Returns:
True if temperature is at or belwo low temperature threshold.

tempOk

public boolean tempOk()
Returns temperature alarm status.
Returns:
True if temperature is between low and high thresholds.

tempHi

public boolean tempHi()
Returns high temperature alarm status.
Returns:
True if temperature is at or exceeds high temperature threshold.

tempStatus

public int tempStatus()
Returns sensor status: low, okay or high.
Returns:
Sensor status (0 = low, 1 = okay, 2 = high)