Easyuino
1.2.0
|
Used to represent the at least supported Ultrasonic Module models enum UltrasonicModule : uint8_t { HC_SR03, HC_SR04, HC_SR05 };. More...
#include <DistanceMeter.h>
Public Member Functions | |
DistanceMeter (IN uint8_t triggerPin, IN uint8_t echoPin) | |
Constructor. More... | |
DistanceMeter (IN uint8_t triggerEchoPin) | |
Contructor used with Ultrasonic Modules that have only one pin for trigger and echo. More... | |
~DistanceMeter () | |
Destructor. | |
bool | begin () |
Used to put the device ready to receive requests. More... | |
void | end () |
Used to stop the device API. More... | |
virtual float | getDistanceCentimeters () |
Gets the last value that the API measured using the Ultrasonic Module. More... | |
float | getDistanceInches () |
Gets the last value that the API measured using the US. More... | |
virtual void | updateDistance () |
Updates the distance of the Ultrasonic Module to the objects in a blocking way. More... | |
![]() | |
Device () | |
Constructor called by every sub-classes. | |
~Device () | |
Destroy all the resources associated with the device. | |
bool | isInitialized () const |
Verify is the device is initialized and ready to use. More... | |
Protected Member Functions | |
float | executeUpdateDistanceBlock (IN float soundSpeed) |
Execute a block distance measurement and calculates the distance based on the sound speed. More... | |
Protected Attributes | |
uint8_t | _triggerPin |
Arduino pin used to trigger the echo wave emission. | |
uint8_t | _echoPin |
Arduino pin that is set to LOW by when reflected echo wave arrives. | |
volatile bool | _isEchoing |
Used to know if it is in a middle of a measurement. | |
volatile float | _distance |
It contains a cached value of the last distance measured. More... | |
![]() | |
bool | _isInitialized |
Used to know if the device API is initialized and ready to receive requests. | |
Used to represent the at least supported Ultrasonic Module models enum UltrasonicModule : uint8_t { HC_SR03, HC_SR04, HC_SR05 };.
DistanceMeter offers a simple API to interact with an Ultrasonic Module to measure distances to objects.
Easyuino::DistanceMeter::DistanceMeter | ( | IN uint8_t | triggerPin, |
IN uint8_t | echoPin | ||
) |
Constructor.
triggerPin | Arduino pin connected to the trigger pin of the Ultrasonic Module |
echoPin | Arduino pin connected to the echo pin of the Ultrasonic Module |
Easyuino::DistanceMeter::DistanceMeter | ( | IN uint8_t | triggerEchoPin | ) |
Contructor used with Ultrasonic Modules that have only one pin for trigger and echo.
triggerEchoPin | Arduino pin connected to the trigger&echo pin of the Ultrasonic Module |
|
virtual |
Used to put the device ready to receive requests.
Normally this have some default behaviour some devices have other overload method with same name that receives other arguments to device customization.
Implements Easyuino::Device.
Reimplemented in Easyuino::DistanceMeterNonBlock.
|
virtual |
Used to stop the device API.
After this the the device will not process API requests.
Implements Easyuino::Device.
Reimplemented in Easyuino::DistanceMeterNonBlock.
|
protected |
Execute a block distance measurement and calculates the distance based on the sound speed.
soundSpeed | (Cm/Sec) Sound speed to introduce in the calculation |
|
virtual |
Gets the last value that the API measured using the Ultrasonic Module.
Reimplemented in Easyuino::DistanceMeterNonBlock, and Easyuino::DistanceMeterAccurate.
float Easyuino::DistanceMeter::getDistanceInches | ( | ) |
Gets the last value that the API measured using the US.
|
virtual |
Updates the distance of the Ultrasonic Module to the objects in a blocking way.
The new distance value is available using getDistanceCentimeters() or getDistanceInches() method after calling this method.
Reimplemented in Easyuino::DistanceMeterNonBlock.
|
protected |
It contains a cached value of the last distance measured.
Avoid calculate all the time.