TempSensor_NXP_Arduino 0.2
Temperature sensor device operation sample code for Arduino
Loading...
Searching...
No Matches
TempSensor.cpp
Go to the documentation of this file.
1#include "TempSensor.h"
2
3/* TempSensor class ******************************************/
4
5TempSensor::TempSensor( uint8_t i2c_address ) : I2C_device( i2c_address )
6{
7 // do nothing.
8 // leave it in default state.
9}
10
12{
13}
14
15/* LM75B class ******************************************/
16
17LM75B::LM75B( uint8_t i2c_address ) : TempSensor( i2c_address )
18{
19 // do nothing.
20 // leave it in default state.
21}
22
24{
25}
26
28{
29 return read_r16( Temp ) / 256.0;
30}
31
32void LM75B::thresholds( float v0, float v1 )
33{
34 float higher = (v0 < v1) ? v1 : v0;
35 float lower = (v0 < v1) ? v0 : v1;
36
37 write_r16( Tos, ((uint16_t)(higher * 256.0)) & 0xFF80 );
38 write_r16( Thyst, ((uint16_t)(lower * 256.0)) & 0xFF80 );
39}
40
41void LM75B::os_mode( mode flag )
42{
43 bit_op8( Conf, ~0x02, flag << 1 );
44}
45
46
47/* PCT2075 class ******************************************/
48PCT2075::PCT2075( uint8_t i2c_address ) : LM75B( i2c_address )
49{
50 // do nothing.
51 // leave it in default state.
52}
53
55{
56}
57
58/* P3T1085 class ******************************************/
59
60P3T1085::P3T1085( uint8_t i2c_address ) : LM75B( i2c_address )
61{
62 // do nothing.
63 // leave it in default state.
64}
65
67{
68}
69
70void P3T1085::thresholds( float v0, float v1 )
71{
72 float higher = (v0 < v1) ? v1 : v0;
73 float lower = (v0 < v1) ? v0 : v1;
74
75 write_r16( T_HIGH, ((uint16_t)(higher * 256.0)) & 0xFFF0 );
76 write_r16( T_LOW, ((uint16_t)(lower * 256.0)) & 0xFFF0 );
77}
78
80{
81 bit_op16( Conf, ~0x0400, flag << 10 );
82}
83
84bool P3T1085::clear( void )
85{
86 return (read_r16( Conf ) & 0x1000) ? true : false;
87}
88
float temp(void)
Definition: TempSensor.cpp:27
@ Temp
Definition: TempSensor.h:56
@ Conf
Definition: TempSensor.h:57
@ Tos
Definition: TempSensor.h:59
@ Thyst
Definition: TempSensor.h:58
~LM75B()
Definition: TempSensor.cpp:23
void thresholds(float v0, float v1)
Definition: TempSensor.cpp:32
void os_mode(mode flag)
Definition: TempSensor.cpp:41
LM75B(uint8_t i2c_address=(0x90 > > 1))
Definition: TempSensor.cpp:17
P3T1085(uint8_t i2c_address=(0x90 > > 1))
Definition: TempSensor.cpp:60
bool clear(void)
Definition: TempSensor.cpp:84
void os_mode(mode flag)
Definition: TempSensor.cpp:79
void thresholds(float v0, float v1)
Definition: TempSensor.cpp:70
PCT2075(uint8_t i2c_address=(0x90 > > 1))
Definition: TempSensor.cpp:48
TempSensor(uint8_t i2c_address)
Definition: TempSensor.cpp:5
virtual ~TempSensor()
Definition: TempSensor.cpp:11