Interface library for the Devantech SRF02/SRF08 ultrasonic i2c rangers. Depends on I2cRtosDriver lib!
Srf0208IF Class Reference
common base interface class for SRF02 and SRF08 utrasonic rangers More...
#include <Srf0208IF.h>
Inherited by Srf02IF, and Srf08IF.
Public Member Functions | |
Srf0208IF (int adr, I2CMasterRtos &i2c) | |
The constructor. | |
bool | triggerRanging () |
Trigger ranging. | |
int | readTransitTime_us () |
Read back measured transit time in us of the last triggerRanging() or triggerEchoMeasurement() request. | |
int | readDistance_mm () |
Read back measured distance in mm of the triggerRanging() or triggerEchoMeasurement() request. | |
void | resetI2CAdress (int newAddress) |
Assign a new adress to the SRF ranger device. | |
int | readSWRevision () |
Reads the SRF's SW revision. | |
bool | rangingCompleted () |
Returns true if ranging is done. | |
Static Public Member Functions | |
static int | twoByte2int (const char *data) |
little helper that translates two raw bytes into a word | |
static int | time2dist_us2mm (int us) |
little helper that translates the us transit time into a distance in mm | |
Static Public Attributes | |
static const int | sonicSpeed = 344 |
sonic speed in m/s @ 21C ... |
Detailed Description
common base interface class for SRF02 and SRF08 utrasonic rangers
Definition at line 11 of file Srf0208IF.h.
Constructor & Destructor Documentation
Srf0208IF | ( | int | adr, |
I2CMasterRtos & | i2c | ||
) |
The constructor.
Definition at line 34 of file Srf0208IF.h.
Member Function Documentation
bool rangingCompleted | ( | ) |
Returns true if ranging is done.
Definition at line 61 of file Srf0208IF.h.
int readDistance_mm | ( | ) |
Read back measured distance in mm of the triggerRanging() or triggerEchoMeasurement() request.
Depending on the distance the Measurement takes up to 66ms.
- Returns:
- -1 on error
Definition at line 48 of file Srf0208IF.h.
int readSWRevision | ( | ) |
int readTransitTime_us | ( | ) |
Read back measured transit time in us of the last triggerRanging() or triggerEchoMeasurement() request.
Depending on the distance the Measurement takes up to 66ms.
- Returns:
- -1 on error
Definition at line 13 of file Srf0208IF.cpp.
void resetI2CAdress | ( | int | newAddress ) |
Assign a new adress to the SRF ranger device.
Available 8bit addresses: E0, E2, E4 ... FE. Ensure that only one SRF device is connected to the bus
Definition at line 19 of file Srf0208IF.cpp.
static int time2dist_us2mm | ( | int | us ) | [static] |
little helper that translates the us transit time into a distance in mm
Definition at line 24 of file Srf0208IF.h.
bool triggerRanging | ( | ) |
Trigger ranging.
Result can be read back after 66ms via triggerEchoMeasurement().
- Returns:
- true on success
Definition at line 8 of file Srf0208IF.cpp.
static int twoByte2int | ( | const char * | data ) | [static] |
little helper that translates two raw bytes into a word
Definition at line 20 of file Srf0208IF.h.
Field Documentation
const int sonicSpeed = 344 [static] |
sonic speed in m/s @ 21C ...
c=(331.5+0.6*T/C)m/s To calculate the distance in mm: Multiply the us measurement with this constant and divide by 2
Definition at line 31 of file Srf0208IF.h.
Generated on Tue Jul 12 2022 20:48:48 by 1.7.2