Maxbotix ultrasonic distance sensor library
Fork of MaxbotixDriver by
Sonar Class Reference
Object representation of a sonar instance. More...
#include <sonar.h>
Public Member Functions | |
Sonar (PinName input, Timer &t) | |
Sets up the driver and starts taking measurements. | |
int | readCm () |
Returns range in cm as int. | |
int | read () |
Returns range in uS as int. | |
operator int () | |
Returns the range in CM as an int. | |
bool | getRange (int *outRawDistance, int *outDistance, float temperature) |
getrange - Get the range in cm. |
Detailed Description
Object representation of a sonar instance.
Definition at line 12 of file sonar.h.
Constructor & Destructor Documentation
Sonar | ( | PinName | input, |
Timer & | t | ||
) |
Member Function Documentation
bool getRange | ( | int * | outRawDistance, |
int * | outDistance, | ||
float | temperature | ||
) |
getrange - Get the range in cm.
Need to enable sensor first, waiting briefly for it to power up. Request temperature sensor to take a reading. Disable ultrasonic sensor after use for power saving. Returns uncompensated, compensated and temperature values by reference. Calling function can still do checks to determine whether to use reading or not.
- Parameters:
-
outRawDistance - Raw uncompensated distance outDistance - Compensated distance if temperature available, otherwise raw distance outTemperature - Temperature reading
- Returns:
- boolean true returned form function for valid reading. false for <23cm or out of range
Generated on Fri Jul 29 2022 10:14:03 by
![doxygen](doxygen.png)