TempSensor_NXP_Arduino 0.5.3
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/* PCT2075 class ******************************************/
56PCT2075::PCT2075( uint8_t i2c_address ) : LM75B( i2c_address )
57{
58}
59
60PCT2075::PCT2075( TwoWire& wire, uint8_t i2c_address ) : LM75B( wire, i2c_address )
61{
62}
63
65{
66}
67
68/* P3T1755 class ******************************************/
69
70P3T1755::P3T1755( uint8_t i2c_address ) : LM75B( i2c_address )
71{
72}
73
74P3T1755::P3T1755( TwoWire& wire, uint8_t i2c_address ) : LM75B( wire, i2c_address )
75{
76}
77
79{
80}
81
82void P3T1755::thresholds( float v0, float v1 )
83{
84 float higher = (v0 < v1) ? v1 : v0;
85 float lower = (v0 < v1) ? v0 : v1;
86
87 write_r16( T_HIGH, ((uint16_t)(higher * 256.0)) & 0xFFF0 );
88 write_r16( T_LOW, ((uint16_t)(lower * 256.0)) & 0xFFF0 );
89}
90
91/* P3T1085 class ******************************************/
92
93P3T1085::P3T1085( uint8_t i2c_address ) : P3T1755( i2c_address )
94{
95}
96
97P3T1085::P3T1085( TwoWire& wire, uint8_t i2c_address ) : P3T1755( wire, i2c_address )
98{
99}
100
102{
103}
104
106{
107 bit_op16( Conf, ~0x0400, flag << 10 );
108}
109
110bool P3T1085::clear( void )
111{
112 return (read_r16( Conf ) & 0x1000) ? true : false;
113}
virtual float temp(void)
@ Thyst
Definition TempSensor.h:66
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 ~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