annotate service/arduinoNode/arduino-libraries/DallasTemperature/DallasTemperature.h @ 165:af4e9d9f0bd8

some external arduino libs, minus examples and docs Ignore-this: 444126f11a1755109b3b29cbeaa6b9bd
author drewp@bigasterisk.com
date Sat, 11 Apr 2015 01:43:14 -0700
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
165
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
1 #ifndef DallasTemperature_h
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
2 #define DallasTemperature_h
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
3
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
4 #define DALLASTEMPLIBVERSION "3.7.2"
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
5
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
6 // This library is free software; you can redistribute it and/or
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
7 // modify it under the terms of the GNU Lesser General Public
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
8 // License as published by the Free Software Foundation; either
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
9 // version 2.1 of the License, or (at your option) any later version.
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
10
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
11 // set to true to include code for new and delete operators
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
12 #ifndef REQUIRESNEW
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
13 #define REQUIRESNEW false
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
14 #endif
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
15
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
16 // set to true to include code implementing alarm search functions
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
17 #ifndef REQUIRESALARMS
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
18 #define REQUIRESALARMS true
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
19 #endif
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
20
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
21 #include <inttypes.h>
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
22 #include <OneWire.h>
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
23
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
24 // Model IDs
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
25 #define DS18S20MODEL 0x10 // also DS1820
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
26 #define DS18B20MODEL 0x28
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
27 #define DS1822MODEL 0x22
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
28 #define DS1825MODEL 0x3B
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
29
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
30 // OneWire commands
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
31 #define STARTCONVO 0x44 // Tells device to take a temperature reading and put it on the scratchpad
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
32 #define COPYSCRATCH 0x48 // Copy EEPROM
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
33 #define READSCRATCH 0xBE // Read EEPROM
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
34 #define WRITESCRATCH 0x4E // Write to EEPROM
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
35 #define RECALLSCRATCH 0xB8 // Reload from last known
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
36 #define READPOWERSUPPLY 0xB4 // Determine if device needs parasite power
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
37 #define ALARMSEARCH 0xEC // Query bus for devices with an alarm condition
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
38
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
39 // Scratchpad locations
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
40 #define TEMP_LSB 0
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
41 #define TEMP_MSB 1
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
42 #define HIGH_ALARM_TEMP 2
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
43 #define LOW_ALARM_TEMP 3
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
44 #define CONFIGURATION 4
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
45 #define INTERNAL_BYTE 5
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
46 #define COUNT_REMAIN 6
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
47 #define COUNT_PER_C 7
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
48 #define SCRATCHPAD_CRC 8
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
49
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
50 // Device resolution
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
51 #define TEMP_9_BIT 0x1F // 9 bit
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
52 #define TEMP_10_BIT 0x3F // 10 bit
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
53 #define TEMP_11_BIT 0x5F // 11 bit
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
54 #define TEMP_12_BIT 0x7F // 12 bit
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
55
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
56 // Error Codes
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
57 #define DEVICE_DISCONNECTED_C -127
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
58 #define DEVICE_DISCONNECTED_F -196.6
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
59 #define DEVICE_DISCONNECTED_RAW -7040
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
60
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
61 typedef uint8_t DeviceAddress[8];
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
62
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
63 class DallasTemperature
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
64 {
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
65 public:
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
66
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
67 DallasTemperature(OneWire*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
68
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
69 // initialise bus
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
70 void begin(void);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
71
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
72 // returns the number of devices found on the bus
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
73 uint8_t getDeviceCount(void);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
74
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
75 // returns true if address is valid
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
76 bool validAddress(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
77
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
78 // finds an address at a given index on the bus
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
79 bool getAddress(uint8_t*, uint8_t);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
80
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
81 // attempt to determine if the device at the given address is connected to the bus
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
82 bool isConnected(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
83
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
84 // attempt to determine if the device at the given address is connected to the bus
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
85 // also allows for updating the read scratchpad
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
86 bool isConnected(const uint8_t*, uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
87
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
88 // read device's scratchpad
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
89 void readScratchPad(const uint8_t*, uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
90
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
91 // write device's scratchpad
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
92 void writeScratchPad(const uint8_t*, const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
93
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
94 // read device's power requirements
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
95 bool readPowerSupply(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
96
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
97 // get global resolution
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
98 uint8_t getResolution();
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
99
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
100 // set global resolution to 9, 10, 11, or 12 bits
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
101 void setResolution(uint8_t);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
102
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
103 // returns the device resolution: 9, 10, 11, or 12 bits
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
104 uint8_t getResolution(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
105
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
106 // set resolution of a device to 9, 10, 11, or 12 bits
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
107 bool setResolution(const uint8_t*, uint8_t);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
108
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
109 // sets/gets the waitForConversion flag
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
110 void setWaitForConversion(bool);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
111 bool getWaitForConversion(void);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
112
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
113 // sets/gets the checkForConversion flag
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
114 void setCheckForConversion(bool);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
115 bool getCheckForConversion(void);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
116
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
117 // sends command for all devices on the bus to perform a temperature conversion
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
118 void requestTemperatures(void);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
119
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
120 // sends command for one device to perform a temperature conversion by address
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
121 bool requestTemperaturesByAddress(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
122
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
123 // sends command for one device to perform a temperature conversion by index
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
124 bool requestTemperaturesByIndex(uint8_t);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
125
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
126 // returns temperature raw value (12 bit integer of 1/16 degrees C)
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
127 int16_t getTemp(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
128
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
129 // returns temperature in degrees C
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
130 float getTempC(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
131
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
132 // returns temperature in degrees F
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
133 float getTempF(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
134
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
135 // Get temperature for device index (slow)
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
136 float getTempCByIndex(uint8_t);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
137
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
138 // Get temperature for device index (slow)
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
139 float getTempFByIndex(uint8_t);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
140
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
141 // returns true if the bus requires parasite power
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
142 bool isParasitePowerMode(void);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
143
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
144 bool isConversionAvailable(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
145
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
146 #if REQUIRESALARMS
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
147
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
148 typedef void AlarmHandler(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
149
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
150 // sets the high alarm temperature for a device
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
151 // accepts a char. valid range is -55C - 125C
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
152 void setHighAlarmTemp(const uint8_t*, char);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
153
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
154 // sets the low alarm temperature for a device
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
155 // accepts a char. valid range is -55C - 125C
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
156 void setLowAlarmTemp(const uint8_t*, char);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
157
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
158 // returns a signed char with the current high alarm temperature for a device
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
159 // in the range -55C - 125C
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
160 char getHighAlarmTemp(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
161
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
162 // returns a signed char with the current low alarm temperature for a device
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
163 // in the range -55C - 125C
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
164 char getLowAlarmTemp(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
165
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
166 // resets internal variables used for the alarm search
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
167 void resetAlarmSearch(void);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
168
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
169 // search the wire for devices with active alarms
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
170 bool alarmSearch(uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
171
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
172 // returns true if ia specific device has an alarm
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
173 bool hasAlarm(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
174
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
175 // returns true if any device is reporting an alarm on the bus
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
176 bool hasAlarm(void);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
177
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
178 // runs the alarm handler for all devices returned by alarmSearch()
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
179 void processAlarms(void);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
180
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
181 // sets the alarm handler
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
182 void setAlarmHandler(const AlarmHandler *);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
183
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
184 // The default alarm handler
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
185 static void defaultAlarmHandler(const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
186
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
187 #endif
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
188
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
189 // convert from Celsius to Fahrenheit
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
190 static float toFahrenheit(float);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
191
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
192 // convert from Fahrenheit to Celsius
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
193 static float toCelsius(float);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
194
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
195 // convert from raw to Celsius
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
196 static float rawToCelsius(int16_t);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
197
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
198 // convert from raw to Fahrenheit
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
199 static float rawToFahrenheit(int16_t);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
200
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
201 #if REQUIRESNEW
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
202
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
203 // initialize memory area
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
204 void* operator new (unsigned int);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
205
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
206 // delete memory reference
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
207 void operator delete(void*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
208
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
209 #endif
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
210
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
211 private:
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
212 typedef uint8_t ScratchPad[9];
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
213
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
214 // parasite power on or off
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
215 bool parasite;
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
216
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
217 // used to determine the delay amount needed to allow for the
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
218 // temperature conversion to take place
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
219 uint8_t bitResolution;
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
220
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
221 // used to requestTemperature with or without delay
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
222 bool waitForConversion;
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
223
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
224 // used to requestTemperature to dynamically check if a conversion is complete
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
225 bool checkForConversion;
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
226
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
227 // count of devices on the bus
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
228 uint8_t devices;
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
229
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
230 // Take a pointer to one wire instance
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
231 OneWire* _wire;
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
232
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
233 // reads scratchpad and returns the raw temperature
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
234 int16_t calculateTemperature(const uint8_t*, uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
235
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
236 int16_t millisToWaitForConversion(uint8_t);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
237
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
238 void blockTillConversionComplete(uint8_t, const uint8_t*);
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
239
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
240 #if REQUIRESALARMS
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
241
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
242 // required for alarmSearch
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
243 uint8_t alarmSearchAddress[8];
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
244 char alarmSearchJunction;
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
245 uint8_t alarmSearchExhausted;
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
246
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
247 // the alarm handler function pointer
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
248 AlarmHandler *_AlarmHandler;
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
249
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
250 #endif
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
251
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
252 };
af4e9d9f0bd8 some external arduino libs, minus examples and docs
drewp@bigasterisk.com
parents:
diff changeset
253 #endif