Revision:
2:d99d91a7e8f1
Parent:
1:c7753ec66a4b
--- a/hcsr04.h	Sun Mar 18 21:01:49 2012 +0000
+++ b/hcsr04.h	Thu Mar 22 05:49:41 2012 +0000
@@ -1,12 +1,14 @@
+//  Primary Author: David Glover 
+//  March, 2012
+//  ECE 510 Embedded Systems, Roy Kravitz
+//
 // HCSR04 ultrasonic sensor class using interrupts and allowing multiple instances.
 // You can use the same trigger pin for multiple instances, the echo is recieved and 
 // measurement calculated based on the echo input alone (when the echo signal goes high
-// the timer is started, when the echo signal is low the timer value in microseconds
+// the timer is started, when the echo signal goes low the timer value in microseconds
 // is saved as the length, and the timer is stopped and reset.  Length calculation is done
 // when the length is requested (either inches or centimeters) using the appropriate
 // function. 
-//New comment
-
 
 #ifndef MBED_HCSR04_H
 #define MBED_HCSR04_H
@@ -24,7 +26,6 @@
     InterruptIn *_echo_int;                        // pin to receive echo signal
     DigitalOut trigger_out;                    // pin to send the trigger signal
     Timer timer;                            // timer to track length of pulse
-    // int timestart;                            // beginning time of echo pulse
     float value;                            // to store the last pulse length        
 
 public:
@@ -38,34 +39,33 @@
     }
 
 
-
-void calc_measurement() {
-    value = timer.read_us();
-    //value = timer.read_us() - timestart;
-    timer.stop();
-    timer.reset();
-    measuring = false;
-}
-    
-void timer_start() {
-    this->timer.start();
-    measuring = true;
-}
-    
-void trigger(void) {
-    trigger_out.write(1);                      // start trigger signal
-    wait_us(TRIGGER_DELAY); 
-    trigger_out.write(0);                    // end trigger signal
-}
-    
-float inches() {
-    return value / INCHES_DIVISOR;
-}
-    
-float cm() {
-    return value /CM_DIVISOR;
-}
-    
+    void calc_measurement() {
+        value = timer.read_us();
+        //value = timer.read_us() - timestart;
+        timer.stop();
+        timer.reset();
+        measuring = false;
+    }
+        
+    void timer_start() {
+        this->timer.start();
+        measuring = true;
+    }
+        
+    void trigger(void) {
+        trigger_out.write(1);                      // start trigger signal
+        wait_us(TRIGGER_DELAY); 
+        trigger_out.write(0);                    // end trigger signal
+    }
+        
+    float inches() {                    // return distance in inches.
+        return value / INCHES_DIVISOR;
+    }
+        
+    float cm() {                        // return distance in centimeters.
+        return value / CM_DIVISOR;
+    }
+        
 };
 
 #endif
\ No newline at end of file