Fork to fix compiler warnings.

Dependencies:   LinkedList

Fork of DS1820 by Erik -

Files at this revision

API Documentation at this revision

Comitter:
Tejas Kale
Date:
Sat Mar 24 04:00:34 2018 +0100
Parent:
18:688dc6dca163
Commit message:
Add an isValid function to re-search for sensors that error out.

Changed in this revision

DS1820.cpp Show annotated file Show diff for this revision Revisions of this file
DS1820.h Show annotated file Show diff for this revision Revisions of this file
diff -r 688dc6dca163 -r cabdd07a57e7 DS1820.cpp
--- a/DS1820.cpp	Fri Mar 23 23:25:22 2018 +0100
+++ b/DS1820.cpp	Sat Mar 24 04:00:34 2018 +0100
@@ -50,11 +50,13 @@
     
     if (!unassignedProbe(&_datapin, _ROM)) {
         printf("DS18B20:No unassigned DS1820 found!\r\n");
+        valid = false;
     }
     else {
         _datapin.input();
         probes.append(this);
         _parasite_power = !read_power_supply();
+        valid = true;
     }
 }
 
@@ -427,4 +429,7 @@
     return onewire_bit_in(&this->_datapin);
 }
 
+bool DS1820::isValid() {
+    return valid;
+}
 
diff -r 688dc6dca163 -r cabdd07a57e7 DS1820.h
--- a/DS1820.h	Fri Mar 23 23:25:22 2018 +0100
+++ b/DS1820.h	Sat Mar 24 04:00:34 2018 +0100
@@ -107,6 +107,8 @@
       */ 
     bool setResolution(unsigned int resolution);
 
+    bool isValid();
+
 private:
     bool _parasite_power;
     bool _power_mosfet;
@@ -134,6 +136,8 @@
     char _ROM[8];
     char RAM[9];
     
+    bool valid = false;
+
     static LinkedList<node> probes;
 };