Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]
Files | Defines | Enumerations | Functions | Variables

Temperature Sensor
[Lego]

Files

file  lego-temp.h
 

RobotC New Temperature Sensor Driver.


Defines

#define LEGOTMP_I2C_ADDR   0x98
#define LEGOTMP_TEMP   0x00
#define LEGOTMP_CONFIG   0x01

Enumerations

enum  tLEGOTMPAccuracy { A_MIN = 8, A_MEAN1 = 4, A_MEAN2 = 2, A_MAX = 1 }

Functions

bool LEGOTMPreadTemp (tSensors link, float &temp)
bool LEGOTMPreadAccuracy (tSensors link, tLEGOTMPAccuracy &accuracy)
bool LEGOTMPsetAccuracy (tSensors link, tLEGOTMPAccuracy accuracy)
bool LEGOTMPsetSingleShot (tSensors link)
bool LEGOTMPsetContinuous (tSensors link)
bool _LEGOTMPreadConfig (tSensors link, ubyte &config)
tLEGOTMPAccuracy _LEGOTMPconvertAccuracy (ubyte config)
bool _LEGOTMPsetConfig (tSensors link, ubyte &config)

Variables

tByteArray LEGOTMP_I2CRequest
tByteArray LEGOTMP_I2CReply

Detailed Description

Temperature Sensor


Define Documentation

#define LEGOTMP_CONFIG   0x01

Configuration registry (see http://focus.ti.com/lit/ds/symlink/tmp275.pdf)

Definition at line 52 of file lego-temp.h.

#define LEGOTMP_I2C_ADDR   0x98

New LEGO Temperature Sensor I2C device address

Definition at line 50 of file lego-temp.h.

#define LEGOTMP_TEMP   0x00

Temperature value (return on 2 bytes, 1rst : most significant byte, 2nd byte only half used)

Definition at line 51 of file lego-temp.h.


Enumeration Type Documentation

< Command modes definition

Enumerator:
A_MIN 
A_MEAN1 
A_MEAN2 
A_MAX 

Definition at line 58 of file lego-temp.h.


Function Documentation

tLEGOTMPAccuracy _LEGOTMPconvertAccuracy ( ubyte  config )

Retrieve the accuracy level from the config bytes

Note: this is an internal function and should not be called directly.

Parameters:
configthe contents of the register
Returns:
true if no error occured, false if it did

Definition at line 135 of file lego-temp.h.

bool _LEGOTMPreadConfig ( tSensors  link,
ubyte &  config 
)

Read the current configuration register

Note: this is an internal function and should not be called directly.

Parameters:
linkthe LEGO Temp Sensor port number
configthe contents of the register
Returns:
true if no error occured, false if it did

Definition at line 92 of file lego-temp.h.

bool _LEGOTMPsetConfig ( tSensors  link,
ubyte &  config 
)

Set the configuration register

Note: this is an internal function and should not be called directly.

Parameters:
linkthe LEGO Temp Sensor port number
configthe contents of the register
Returns:
true if no error occured, false if it did

Definition at line 116 of file lego-temp.h.

bool LEGOTMPreadAccuracy ( tSensors  link,
tLEGOTMPAccuracy accuracy 
)

Read the temperature sensor's accuracy

Parameters:
linkthe LEGO Temp Sensor port number,
accuracythe accuracy value to be read
Returns:
true if no error occured, false if it did
Examples:
lego-temp-test1.c, and lego-temp-test2.c.

Definition at line 257 of file lego-temp.h.

bool LEGOTMPreadTemp ( tSensors  link,
float &  temp 
)

Read the temperature.

Parameters:
linkthe LEGO Temp Sensor port number
tempthe temperature value,
Returns:
true if no error occured, false if it did

128 to have only the most significant bit (9 bits accuracy - 8 (b1) = 1 bit to keep)

64 to have only the 2 most significant bits

32 to have only the 3 most significant bits

16 to have only the 4 most significant bits

Examples:
lego-temp-test1.c, and lego-temp-test2.c.

Definition at line 173 of file lego-temp.h.

bool LEGOTMPsetAccuracy ( tSensors  link,
tLEGOTMPAccuracy  accuracy 
)

Set the temperature sensor's accuracy

Parameters:
linkthe LEGO Temp Sensor port number
accuracythe accuracy value to be set
Returns:
true if no error occured, false if it did
Examples:
lego-temp-test1.c, and lego-temp-test2.c.

Definition at line 276 of file lego-temp.h.

bool LEGOTMPsetContinuous ( tSensors  link )

Configure the sensor for Continuous mode

Parameters:
linkthe New LEGO Sensor port number
Returns:
true if no error occured, false if it did
Examples:
lego-temp-test1.c.

Definition at line 353 of file lego-temp.h.

bool LEGOTMPsetSingleShot ( tSensors  link )

Configure the sensor for Single Shot mode

Parameters:
linkthe New LEGO Sensor port number
Returns:
true if no error occured, false if it did
Examples:
lego-temp-test2.c.

Definition at line 324 of file lego-temp.h.


Variable Documentation

Array to hold I2C reply data

Definition at line 79 of file lego-temp.h.

Array to hold I2C command data

Definition at line 78 of file lego-temp.h.