Maxbotix ultrasonic distance sensor library
Fork of MaxbotixDriver by
Diff: sonar.cpp
- Revision:
- 1:330989f98a6e
- Parent:
- 0:7e65f5077f5a
- Child:
- 3:c231deea4d36
--- 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