Library for the DS1620 Digital Thermometer

Revision:
2:35526d3a8a04
Parent:
0:45c93163189a
--- a/DS1620.cpp	Sun Mar 08 00:38:29 2015 +0000
+++ b/DS1620.cpp	Sat Dec 12 19:29:43 2015 +0000
@@ -17,6 +17,8 @@
 #include "mbed.h"
 #include "DS1620.h"
 
+#define WRITE_COMPLETE_TIME_MS   (100)        // time for write to complete (100 msec) 
+
 // Constructor
 DS1620::DS1620(PinName dq, PinName clk, PinName rst) : _dq(dq), _clk(clk), _rst(rst)
 {
@@ -37,25 +39,25 @@
 {
     float temp = 0.0;
     unsigned short rawTemp = readTemperatureRaw();
-    temp = rawTemp / 2.0;
+    temp = rawTemp / 2.0f;
     if (rawTemp >= 0x100) {
-        temp -= 256.0;
+        temp -= 256.0f;
     }
     return temp;
 }
 
 float DS1620::getHighResolutionTemperature()
 {
-    float temp = 0.0;
+    float temp = 0.0f;
     unsigned short rawTemp, counter, slope = 0;
     rawTemp = readTemperatureRaw();
     counter = readCounter();
     loadSlope();
     slope = readCounter();
     
-    temp = (rawTemp >> 1) - 0.25;
+    temp = (rawTemp >> 1) - 0.25f;
     if (rawTemp >= 0x100) {
-        temp -= 256.0;
+        temp -= 256.0f;
     }
     temp += ((float)slope - (float)counter) / (float)slope;   
     return temp;
@@ -92,7 +94,7 @@
     shiftOut(WRITE_CONFIG);
     shiftOut(config);
     _rst = 0;
-    wait(0.1);  // Wait for write to complete
+    wait_ms(WRITE_COMPLETE_TIME_MS);  // wait for write to complete
 }
     
 unsigned short DS1620::readTLRaw()
@@ -120,7 +122,7 @@
     shiftOut(tempLSB);
     shiftOut(tempMSB);
     _rst = 0;
-    wait(0.1);
+    wait_ms(WRITE_COMPLETE_TIME_MS);  // wait for write to complete
 }   
     
         
@@ -149,7 +151,7 @@
     shiftOut(tempLSB);
     shiftOut(tempMSB);
     _rst = 0;
-    wait(0.1);
+    wait_ms(WRITE_COMPLETE_TIME_MS);  // wait for write to complete
 }
         
 unsigned short DS1620::readCounter()