Thing Innovations / DS1820

Dependencies:   LinkedList

Fork of DS1820 by Erik -

Files at this revision

API Documentation at this revision

Comitter:
SomeRandomBloke
Date:
Tue Nov 22 16:19:22 2016 +0000
Parent:
13:51a5011dc0ad
Commit message:
Updates

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 51a5011dc0ad -r 206d620315cf DS1820.cpp
--- a/DS1820.cpp	Mon Mar 09 20:41:08 2015 +0000
+++ b/DS1820.cpp	Tue Nov 22 16:19:22 2016 +0000
@@ -13,8 +13,10 @@
         RAM[byte_counter] = 0x00;
     
     if (!unassignedProbe(&_datapin, _ROM))
-        error("No unassigned DS1820 found!\n");
+//        error("No unassigned DS1820 found!\n");
+        _hasProbes = false;
     else {
+        _hasProbes = true;
         _datapin.input();
         probes.append(this);
         _parasite_power = !read_power_supply();
@@ -110,6 +112,8 @@
     bool return_value, Bit_A, Bit_B;
     char byte_counter, bit_mask;
  
+//    if( !_hasProbes ) return false;
+    
     return_value=false;
     while (!DS1820_done_flag) {
         if (!onewire_reset(pin)) {
@@ -201,6 +205,8 @@
 void DS1820::match_ROM() {
 // Used to select a specific device
     int i;
+    if( !_hasProbes ) return;
+
     onewire_reset(&this->_datapin);
     onewire_byte_out( 0x55);  //Match ROM command
     for (i=0;i<8;i++) {
@@ -266,6 +272,8 @@
 int DS1820::convertTemperature(bool wait, devices device) {
     // Convert temperature into scratchpad RAM for all devices at once
     int delay_time = 750; // Default delay time
+    if( !_hasProbes ) return delay_time;
+
     char resolution;
     if (device==all_devices)
         skip_ROM();          // Skip ROM command, will convert for ALL devices
@@ -320,6 +328,8 @@
 
 bool DS1820::setResolution(unsigned int resolution) {
     bool answer = false;
+    if( !_hasProbes ) return false;
+
     resolution = resolution - 9;
     if (resolution < 4) {
         resolution = resolution<<5; // align the bits
diff -r 51a5011dc0ad -r 206d620315cf DS1820.h
--- a/DS1820.h	Mon Mar 09 20:41:08 2015 +0000
+++ b/DS1820.h	Tue Nov 22 16:19:22 2016 +0000
@@ -111,6 +111,7 @@
     bool _parasite_power;
     bool _power_mosfet;
     bool _power_polarity;
+    bool _hasProbes;
     
     static char CRC_byte(char _CRC, char byte );
     static bool onewire_reset(DigitalInOut *pin);