my version

Fork of HCSR04 by Awadh Al Shukaili

Files at this revision

API Documentation at this revision

Comitter:
feupos
Date:
Sat Nov 18 18:27:18 2017 +0000
Parent:
0:0bda99bb39a4
Commit message:
set to float

Changed in this revision

HCSR04.cpp Show annotated file Show diff for this revision Revisions of this file
HCSR04.h Show annotated file Show diff for this revision Revisions of this file
diff -r 0bda99bb39a4 -r 62f97e90a58c HCSR04.cpp
--- a/HCSR04.cpp	Tue Oct 18 14:32:12 2011 +0000
+++ b/HCSR04.cpp	Sat Nov 18 18:27:18 2017 +0000
@@ -10,7 +10,7 @@
 // 
 
 //return echo duration in us (refer to digram above)
-long HCSR04::echo_duration() {
+float HCSR04::echo_duration() {
     timer.reset();
     trig = 0;
     wait_us(2);
@@ -27,7 +27,7 @@
 //return distance to nearest obstacle or returns -1 
 //if no obstacle within range
 //set sys to cm or inch accordingly
-long HCSR04::distance(int sys){
+float HCSR04::distance(int sys){
     duration = echo_duration();
     if(duration > 30000)
         return -1;
diff -r 0bda99bb39a4 -r 62f97e90a58c HCSR04.h
--- a/HCSR04.h	Tue Oct 18 14:32:12 2011 +0000
+++ b/HCSR04.h	Sat Nov 18 18:27:18 2017 +0000
@@ -26,14 +26,14 @@
 class HCSR04 {
   public:
     HCSR04(PinName t, PinName e);
-    long echo_duration();
-    long distance(int sys);
+    float echo_duration();
+    float distance(int sys);
 
     private:
         DigitalOut trig;
         DigitalIn echo;
         Timer timer;
-        long duration,distacne_cm,distance_inc;
+        float duration,distacne_cm,distance_inc;
 };
 
 #endif
\ No newline at end of file