@@ -137,7 +137,7 @@ class DS18B20 : public OWI::Device {
137
137
}
138
138
139
139
/* *
140
- * Return remaining convertion time in milliseconds.
140
+ * Return remaining conversion time in milliseconds.
141
141
* @return milliseconds remaining.
142
142
*/
143
143
uint16_t conversion_time ()
@@ -150,6 +150,18 @@ class DS18B20 : public OWI::Device {
150
150
return (0 );
151
151
}
152
152
153
+ /* *
154
+ * Check if the temperature conversion is completed.
155
+ * @return true(1) if ready otherwise false(0).
156
+ */
157
+ bool convert_ready ()
158
+ {
159
+ if (!m_converting) return (true );
160
+ bool res = m_owi.read (1 );
161
+ if (res) m_converting = false ;
162
+ return (res);
163
+ }
164
+
153
165
/* *
154
166
* Delay until the temperature conversion is completed
155
167
* by polling the sensors.
@@ -158,16 +170,15 @@ class DS18B20 : public OWI::Device {
158
170
bool convert_await ()
159
171
{
160
172
if (!m_converting) return (false );
161
- while (m_owi.read (1 ) == 0 ) delayMicroseconds (100 );
162
- m_converting = false ;
173
+ while (!convert_ready ()) delay (1 );
163
174
return (true );
164
175
}
165
176
166
177
/* *
167
- * Read the contents of the scratchpad to local memory. An internal
168
- * delay will occur if a convert_request () is pending. The delay is
169
- * at most max conversion time (750 ms) . Call with match parameter
170
- * false if used with search_rom().
178
+ * Read the contents of the scratchpad to local memory. Call
179
+ * convert_ready(), convert_await () or delay with amount from
180
+ * conversion_time() before reading . Call with match parameter false
181
+ * if used with search_rom().
171
182
* @param[in] match rom code (default true).
172
183
* @return true(1) if successful otherwise false(0).
173
184
*/
@@ -180,7 +191,9 @@ class DS18B20 : public OWI::Device {
180
191
181
192
/* *
182
193
* Write the contents of the scratchpad triggers and configuration
183
- * (3 bytes) to device.
194
+ * (3 bytes) to device. Call with match parameter false if used with
195
+ * search_rom().
196
+ * @param[in] match rom code (default true).
184
197
* @return true(1) if successful otherwise false(0).
185
198
*/
186
199
bool write_scratchpad (bool match = true )
@@ -192,23 +205,26 @@ class DS18B20 : public OWI::Device {
192
205
193
206
/* *
194
207
* Copy device scratchpad triggers and configuration data to device
195
- * EEPROM.
208
+ * EEPROM. Call with match parameter false if used with search_rom().
209
+ * @param[in] match rom code (default true).
196
210
* @return true(1) if successful otherwise false(0).
197
211
*/
198
- bool copy_scratchpad ()
212
+ bool copy_scratchpad (bool match = true )
199
213
{
200
- if (!m_owi.match_rom (m_rom)) return (false );
214
+ if (match && !m_owi.match_rom (m_rom)) return (false );
201
215
m_owi.write (COPY_SCRATCHPAD);
202
216
return (true );
203
217
}
204
218
205
219
/* *
206
220
* Recall the alarm triggers and configuration from device EEPROM.
221
+ * Call with match parameter false if used with search_rom().
222
+ * @param[in] match rom code (default true).
207
223
* @return true(1) if successful otherwise false(0).
208
224
*/
209
- bool recall ()
225
+ bool recall (bool match = true )
210
226
{
211
- if (!m_owi.match_rom (m_rom)) return (false );
227
+ if (match && !m_owi.match_rom (m_rom)) return (false );
212
228
m_owi.write (RECALL_E);
213
229
return (true );
214
230
}
0 commit comments