JSN-SR04_Gen3_RK
Public Types | Public Member Functions | Data Fields
JSN_SR04_Gen3::DistanceResult Class Reference

Structure passed to the callback when the distance has been retrieved. More...

#include <JSN-SR04_Gen3_RK.h>

Inheritance diagram for JSN_SR04_Gen3::DistanceResult:
JSN_SR04_Gen3::Distance

Public Types

enum class  Status : int {
  SUCCESS = 0 , ERROR , RANGE_ERROR , BUSY ,
  IN_PROGRESS , ENTER_ALARM , EXIT_ALARM
}
 Status of the call. More...
 

Public Member Functions

Status getStatus () const
 Get the Status value for this result. More...
 
bool success () const
 Helper function to return true if the Status is SUCCESS. More...
 
- Public Member Functions inherited from JSN_SR04_Gen3::Distance
 Distance ()
 Construct a new Distance object with a distance of 0.
 
 Distance (double valueM)
 Construct a new Distance object with a distance in meters. More...
 
 Distance (const Distance &value)
 Construct a new Distance object from another Distance object. More...
 
Distanceoperator= (const Distance &value)
 Copy the distance value from another Distance object. More...
 
void setDistanceM (double distanceM)
 Set the Distance in meters. More...
 
double getDistanceM () const
 Get the Distance in meters. More...
 
void cm (double cm)
 Set the distance in centimeters. More...
 
double cm () const
 Get the value of the Distance in centimeters. More...
 
void mm (double mm)
 Set the distance in millimeter. More...
 
double mm () const
 Get the value of the Distance in millimeters. More...
 
void inch (double inch)
 Set the distance in inches. More...
 
double inch () const
 Get the value of the Distance in inches. More...
 

Data Fields

Status status = Status::ERROR
 Current status value.
 
- Data Fields inherited from JSN_SR04_Gen3::Distance
double distanceM = 0.0
 The value of the distance in meters.
 

Detailed Description

Structure passed to the callback when the distance has been retrieved.

This includes a Status enum for the result status, and optionally a distance as this class is derived from class Distance. Thus you can use the inherited methods such as cm(), mm(), and inch() to get the distance in centimeters, millimeters, or inches, for example.

Member Enumeration Documentation

◆ Status

enum class JSN_SR04_Gen3::DistanceResult::Status : int
strong

Status of the call.

Enumerator
SUCCESS 

Success, got a valid looking measurement.

ERROR 

An internal error (problem with the I2S peripheral, etc.)

RANGE_ERROR 

Too close or too far away to detect.

BUSY 

Called before the previous call completed.

IN_PROGRESS 

Call is in progress (getting sample from sensor)

ENTER_ALARM 

When using distance alarm, entering alarm state.

EXIT_ALARM 

When using distance alarm, exiting alarm state.

Member Function Documentation

◆ getStatus()

Status JSN_SR04_Gen3::DistanceResult::getStatus ( ) const
inline

Get the Status value for this result.

Returns
Status

◆ success()

bool JSN_SR04_Gen3::DistanceResult::success ( ) const
inline

Helper function to return true if the Status is SUCCESS.

Returns
true
false

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