lejos.nxt
Class TemperatureSensor

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.TemperatureSensor
All Implemented Interfaces:
SensorConstants

public class TemperatureSensor
extends I2CSensor

Lego Education Temperature Sensor 9749

Author:
Michael Mirwaldt

Field Summary
protected static int I2C_ADDRESS
           
protected static int REG_CONFIG
           
protected static int REG_TEMPERATURE
           
protected static int REG_THIGH
           
protected static int REG_TLOW
           
static int RESOLUTION_10BIT
          0.25 °C accuracy
static int RESOLUTION_11BIT
          0.125 °C accuracy
static int RESOLUTION_12BIT
          0.0625 C° accuracy
static int RESOLUTION_9BIT
          0.5 °C accuracy
 
Fields inherited from class lejos.nxt.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION
 
Fields inherited from interface lejos.nxt.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, GREEN, GREEN_INDEX, MAX_AD_RAW, MAX_TYPE, MIN_TYPE, MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
 
Constructor Summary
TemperatureSensor(I2CPort port)
           
 
Method Summary
 String getProductID()
          Sensor does not support Lego standard I2C layout.
 int getResolution()
          Returns current resolution.
static int getSamplingDelay(int resolution)
          Returns, how long it takes the sensor to measure the temperature at the given resolution.
 float getTemperature()
           
 String getVendorID()
          Sensor does not support Lego standard I2C layout.
 String getVersion()
          Sensor does not support Lego standard I2C layout.
 void setResolution(int resolution)
          Sets current resolution.
 
Methods inherited from class lejos.nxt.I2CSensor
fetchString, getAddress, getData, getData, getPort, sendData, sendData, sendData, setAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

I2C_ADDRESS

protected static final int I2C_ADDRESS
See Also:
Constant Field Values

REG_TEMPERATURE

protected static final int REG_TEMPERATURE
See Also:
Constant Field Values

REG_CONFIG

protected static final int REG_CONFIG
See Also:
Constant Field Values

REG_TLOW

protected static final int REG_TLOW
See Also:
Constant Field Values

REG_THIGH

protected static final int REG_THIGH
See Also:
Constant Field Values

RESOLUTION_9BIT

public static final int RESOLUTION_9BIT
0.5 °C accuracy

See Also:
Constant Field Values

RESOLUTION_10BIT

public static final int RESOLUTION_10BIT
0.25 °C accuracy

See Also:
Constant Field Values

RESOLUTION_11BIT

public static final int RESOLUTION_11BIT
0.125 °C accuracy

See Also:
Constant Field Values

RESOLUTION_12BIT

public static final int RESOLUTION_12BIT
0.0625 C° accuracy

See Also:
Constant Field Values
Constructor Detail

TemperatureSensor

public TemperatureSensor(I2CPort port)
Method Detail

getSamplingDelay

public static int getSamplingDelay(int resolution)
Returns, how long it takes the sensor to measure the temperature at the given resolution.

Parameters:
resolution - RESOLUTION_9BIT, RESOLUTION_10BIT, RESOLUTION_11BIT, or RESOLUTION_12BIT
Returns:
number of milliseconds

getTemperature

public float getTemperature()

getResolution

public int getResolution()
Returns current resolution.

Returns:
RESOLUTION_9BIT, RESOLUTION_10BIT, RESOLUTION_11BIT, or RESOLUTION_12BIT

setResolution

public void setResolution(int resolution)
Sets current resolution.

Parameters:
resolution - RESOLUTION_9BIT, RESOLUTION_10BIT, RESOLUTION_11BIT, or RESOLUTION_12BIT

getVendorID

public String getVendorID()
Sensor does not support Lego standard I2C layout.

Overrides:
getVendorID in class I2CSensor
Returns:
vendor identifier

getProductID

public String getProductID()
Sensor does not support Lego standard I2C layout.

Overrides:
getProductID in class I2CSensor
Returns:
product identifier

getVersion

public String getVersion()
Sensor does not support Lego standard I2C layout.

Overrides:
getVersion in class I2CSensor
Returns:
version number