TempSensor_NXP_Arduino 0.5.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}
8
9TempSensor::TempSensor( TwoWire& wire, uint8_t i2c_address ) : I2C_device( wire, i2c_address )
10{
11}
12
14{
15}
16
18{
19 return temp();
20}
21
22/* LM75B class ******************************************/
23
24LM75B::LM75B( uint8_t i2c_address ) : TempSensor( i2c_address )
25{
26}
27
28LM75B::LM75B( TwoWire& wire, uint8_t i2c_address ) : TempSensor( wire, i2c_address )
29{
30}
31
33{
34}
35
37{
38 return read_r16( Temp ) / 256.0;
39}
40
41void LM75B::thresholds( float v0, float v1 )
42{
43 float higher = (v0 < v1) ? v1 : v0;
44 float lower = (v0 < v1) ? v0 : v1;
45
46 write_r16( Tos, ((uint16_t)(higher * 256.0)) & 0xFF80 );
47 write_r16( Thyst, ((uint16_t)(lower * 256.0)) & 0xFF80 );
48}
49
50void LM75B::os_mode( mode flag )
51{
52 bit_op8( Conf, ~0x02, flag << 1 );
53}
54
55
56/* PCT2075 class ******************************************/
57PCT2075::PCT2075( uint8_t i2c_address ) : LM75B( i2c_address )
58{
59}
60
61PCT2075::PCT2075( TwoWire& wire, uint8_t i2c_address ) : LM75B( wire, i2c_address )
62{
63}
64
66{
67}
68
69/* P3T1085 class ******************************************/
70
71P3T1085::P3T1085( uint8_t i2c_address ) : LM75B( i2c_address )
72{
73}
74
75P3T1085::P3T1085( TwoWire& wire, uint8_t i2c_address ) : LM75B( wire, i2c_address )
76{
77}
78
80{
81}
82
83void P3T1085::thresholds( float v0, float v1 )
84{
85 float higher = (v0 < v1) ? v1 : v0;
86 float lower = (v0 < v1) ? v0 : v1;
87
88 write_r16( T_HIGH, ((uint16_t)(higher * 256.0)) & 0xFFF0 );
89 write_r16( T_LOW, ((uint16_t)(lower * 256.0)) & 0xFFF0 );
90}
91
93{
94 bit_op16( Conf, ~0x0400, flag << 10 );
95}
96
97bool P3T1085::clear( void )
98{
99 return (read_r16( Conf ) & 0x1000) ? true : false;
100}
101
102/* P3T1755 class ******************************************/
103
104P3T1755::P3T1755( uint8_t i2c_address ) : P3T1085( i2c_address )
105{
106}
107
108P3T1755::P3T1755( TwoWire& wire, uint8_t i2c_address ) : P3T1085( wire, i2c_address )
109{
110}
111
113{
114}
115
117{
118 bit_op8( Conf, ~0x02, flag << 1 );
119}
120
121bool P3T1755::clear( void )
122{
123 read_r8( Conf );
124 return true;
125}
126
virtual float temp(void)
@ Thyst
Definition TempSensor.h:67
virtual ~LM75B()
virtual void thresholds(float v0, float v1)
virtual void os_mode(mode flag)
LM75B(uint8_t i2c_address=(0x90 > > 1))
P3T1085(uint8_t i2c_address=(0x90 > > 1))
virtual bool clear(void)
virtual ~P3T1085()
virtual void os_mode(mode flag)
virtual void thresholds(float v0, float v1)
virtual bool clear(void)
virtual void os_mode(mode flag)
virtual ~P3T1755()
P3T1755(uint8_t i2c_address=(0x98 > > 1))
PCT2075(uint8_t i2c_address=(0x90 > > 1))
virtual ~PCT2075()
virtual float read(void)
TempSensor(uint8_t i2c_address)
Definition TempSensor.cpp:5
virtual ~TempSensor()
virtual float temp(void)=0