Dallas / Maxim DS1820 1-Wire library. For communication with multiple DS1820 on a single 1-Wire bus. Also supports DS18S20 and DS18B20.

Revision:
4:c2b93dbd6a9e
Parent:
3:3e89eafb60c2
Child:
5:31e245719610
--- a/DS1820.cpp	Mon Jan 29 03:39:38 2018 +0000
+++ b/DS1820.cpp	Fri Sep 28 22:29:43 2018 +0000
@@ -361,21 +361,24 @@
     if (reading & 0x8000) { // negative degrees C
         reading = 0-((reading ^ 0xffff) + 1); // 2's comp then convert to signed int
     }
-    answer = reading +0.0; // convert to floating point
+    answer = reading +0.0f; // convert to floating point
     if ( FAMILY_CODE == FAMILY_CODE_DS18B20 ) {
-        answer = answer / 8.0;
+        answer = answer / 8.0f;
+        printf("FAMILY_CODE_DS18B20\r\n");
     }
     else {
-        remaining_count = RAM[6];
-        count_per_degree = RAM[7];
-        answer = answer - 0.25 + (count_per_degree - remaining_count) / count_per_degree;
+        remaining_count = RAM[2];
+        count_per_degree = RAM[3];
+        answer = answer - 0.25f + (count_per_degree - remaining_count) / count_per_degree;
+        printf("FAMILY_CODE_OTHER\r\n");
     }
     if (scale=='C' or scale=='c')
-        answer = answer / 2.0;
+        answer = answer / 2.0f;
     else
         // Convert to deg F
-        answer = answer * 9.0 / 10.0 + 32.0;
-    return answer;
+        answer = answer * 9.0f / 10.0f + 32.0f;
+    //return answer;
+    return reading;
 }
  
 bool DS1820::read_power_supply(devices device) {