Maxbotix ultrasonic distance sensor library

Fork of MaxbotixDriver by Daniel Casner

Files at this revision

API Documentation at this revision

Comitter:
SomeRandomBloke
Date:
Sun Dec 27 19:47:07 2015 +0000
Parent:
0:7e65f5077f5a
Child:
2:911740f19198
Commit message:
updates to return raw pulse

Changed in this revision

sonar.cpp Show annotated file Show diff for this revision Revisions of this file
sonar.h Show annotated file Show diff for this revision Revisions of this file
--- a/sonar.cpp	Wed Nov 21 20:47:05 2012 +0000
+++ b/sonar.cpp	Sun Dec 27 19:47:07 2015 +0000
@@ -13,6 +13,10 @@
     return range;
 }
 
+int Sonar::readCm() {
+    return range  / 58; // 58uS per CM
+}
+
 Sonar::operator int() {
     return read();
 }
@@ -24,5 +28,5 @@
 void Sonar::pulseStop() {
     int endTime = time.read_us();
     if (endTime < pulseStartTime) return; // Escape if there's been a roll over
-    range = (endTime - pulseStartTime) / 58; // 58uS per CM
+    range = (endTime - pulseStartTime); //   / 58; // 58uS per CM
 }
\ No newline at end of file
--- a/sonar.h	Wed Nov 21 20:47:05 2012 +0000
+++ b/sonar.h	Sun Dec 27 19:47:07 2015 +0000
@@ -20,6 +20,9 @@
     Sonar(PinName input, Timer& t);
     
     /// Returns range in cm as int
+    int readCm();
+    
+    /// Returns range in mS as int
     int read();
     
     /// Returns the range in CM as an int