RBCX
Library for the RB3204-RBCX board with the ESP32 by RoboticsBrno.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
rb::Ultrasound Class Reference

#include <RBCXUltrasound.h>

Public Types

typedef std::function< bool(uint32_t)> callback_t
 

Public Member Functions

uint32_t lastDistanceMm () const
 Get the last measured distance in mm. If the last measurement was invalid or not yet done, returns 0. More...
 
uint32_t lastDurationUs () const
 Get the last measured duration in us. If the last measurement was invalid or not yet done, returns 0. More...
 
bool isLastMeasurementValid () const
 Returns true if the last measurement was valid Tests if the last measurement was`nt 0. More...
 
void setSpeedOfSound (float speedOfSoundInMetersPerSecond=defaultSpeedOfSound)
 Set the speed of sound in m/s. More...
 
float getSpeedOfSound () const
 Get the speed of sound in m/s. More...
 
void measureAsync (callback_t callback=nullptr)
 Asynchronously measure the distance to an object. The callback will be called when the measurement is done. More...
 
uint32_t measure ()
 Synchronously measure the distance to an object. This function will block until the measurement is done. More...
 

Static Public Attributes

static constexpr float defaultSpeedOfSound = 347.13f
 < Default is speed at 25C, 50%, 101 kPa More...
 

Friends

class Manager
 

Member Typedef Documentation

◆ callback_t

typedef std::function<bool(uint32_t)> rb::Ultrasound::callback_t

Member Function Documentation

◆ getSpeedOfSound()

float rb::Ultrasound::getSpeedOfSound ( ) const
inline

Get the speed of sound in m/s.

◆ isLastMeasurementValid()

bool rb::Ultrasound::isLastMeasurementValid ( ) const
inline

Returns true if the last measurement was valid Tests if the last measurement was`nt 0.

Returns
bool

◆ lastDistanceMm()

uint32_t rb::Ultrasound::lastDistanceMm ( ) const
inline

Get the last measured distance in mm. If the last measurement was invalid or not yet done, returns 0.

Returns
uint32_t

◆ lastDurationUs()

uint32_t rb::Ultrasound::lastDurationUs ( ) const
inline

Get the last measured duration in us. If the last measurement was invalid or not yet done, returns 0.

Returns
uint32_t

◆ measure()

uint32_t rb::Ultrasound::measure ( )

Synchronously measure the distance to an object. This function will block until the measurement is done.

Returns
uint32_t

◆ measureAsync()

void rb::Ultrasound::measureAsync ( callback_t  callback = nullptr)

Asynchronously measure the distance to an object. The callback will be called when the measurement is done.

Parameters
callbackis a function which will be called when the measurement is done.

◆ setSpeedOfSound()

void rb::Ultrasound::setSpeedOfSound ( float  speedOfSoundInMetersPerSecond = defaultSpeedOfSound)

Set the speed of sound in m/s.

Friends And Related Function Documentation

◆ Manager

friend class Manager
friend

Member Data Documentation

◆ defaultSpeedOfSound

constexpr float rb::Ultrasound::defaultSpeedOfSound = 347.13f
staticconstexpr

< Default is speed at 25C, 50%, 101 kPa


The documentation for this class was generated from the following files: