-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathds1820.h
40 lines (32 loc) · 862 Bytes
/
ds1820.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//https://github.com/billprozac/ds1820
// Oringal Paste Bin - http://pastebin.com/iYcDkrLw
#include <limits.h>
#define ONEWIRE_FAMILY_DS18B20 0x28
#define ONEWIRE_FAMILY_DS18S20 0x10
#define INVALID_TEMPERATURE_VALUE INT_MIN
class OneWire;
class DS1820Sensor {
public:
DS1820Sensor();
bool Update(unsigned long clock);
void PrintTemp(void);
long GetTemp();
bool Busy();
bool Initialized();
void Reset();
int CompareId(uint8_t* other);
void Initialize(OneWire* bus, uint8_t* addr);
uint8_t m_addr[8];
private:
bool ResetAndSelect();
bool StartConversion();
bool FetchConversion();
void Reset(uint8_t *addr);
private:
OneWire* m_bus;
bool m_initialized;
bool m_converting;
unsigned long m_conversion_start_clock;
int m_temp;
bool m_temp_is_valid;
};