Proof of concept for distance and temperature monitoring

Dependencies:   mbed mbedConnectorInterface mbedEndpointNetwork

Revision:
8:c69fe28366d8
Parent:
0:cb422b231ea5
Child:
10:338191178cbf
diff -r 939fdc8df95b -r c69fe28366d8 hcsr04.h
--- a/hcsr04.h	Wed May 06 02:53:36 2015 +0000
+++ b/hcsr04.h	Wed May 06 04:02:08 2015 +0000
@@ -29,9 +29,13 @@
 /** HCSR04 Class(es)
  */
 
+// TODO(CJF): steal clever logic from https://code.google.com/p/arduino-new-ping/ ?
+
 class HCSR04
 {
 public:
+    static const double kMicrosecondsToCentimeters = 343.0 / 20000;
+    
     /** Create a HCSR04 object connected to the specified pin
     * @param pin i/o pin to connect to
     */
@@ -41,7 +45,7 @@
     /** Return the distance from obstacle in cm
     * @param distance in cms and returns -1, in case of failure
     */
-    unsigned int get_dist_cm(void);
+    double get_dist_cm(void);
     /** Return the pulse duration equal to sonic waves travelling to obstacle and back to receiver.
     * @param pulse duration in microseconds.
     */
@@ -62,7 +66,6 @@
     DigitalOut  trigger;
     InterruptIn echo;
     unsigned int pulsedur;
-    unsigned int distance;
 };
 
 #endif
\ No newline at end of file