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

Utility class for holding a distance. More...

#include <JSN-SR04_Gen3_RK.h>

Inheritance diagram for JSN_SR04_Gen3::Distance:
JSN_SR04_Gen3::DistanceAlarm JSN_SR04_Gen3::DistanceCm JSN_SR04_Gen3::DistanceInch JSN_SR04_Gen3::DistanceResult JSN_SR04_Gen3::DistanceAlarmGreaterThan JSN_SR04_Gen3::DistanceAlarmLessThan

Public Member Functions

 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

double distanceM = 0.0
 The value of the distance in meters.
 

Detailed Description

Utility class for holding a distance.

The storage value is in meters, but there are accessors for cm, mm, and inches. This is used for both getting distances (the sensor value) as well as setting distances (for distance alarm mode).

Constructor & Destructor Documentation

◆ Distance() [1/2]

JSN_SR04_Gen3::Distance::Distance ( double  valueM)
inline

Construct a new Distance object with a distance in meters.

Parameters
valueMdistance in meters (double floating point)

◆ Distance() [2/2]

JSN_SR04_Gen3::Distance::Distance ( const Distance value)
inline

Construct a new Distance object from another Distance object.

Parameters
valueThe object to copy the distance from

Member Function Documentation

◆ cm() [1/2]

double JSN_SR04_Gen3::Distance::cm ( ) const
inline

Get the value of the Distance in centimeters.

Returns
double Distance in centimeters

◆ cm() [2/2]

void JSN_SR04_Gen3::Distance::cm ( double  cm)
inline

Set the distance in centimeters.

Parameters
cmDistance in centimeters (double floating point)

Internally, the distance is stored in meters, but this sets the value in centimeters. You can mix-and-match, for example you can get the distance in inches after setting it in centimeters.

◆ getDistanceM()

double JSN_SR04_Gen3::Distance::getDistanceM ( ) const
inline

Get the Distance in meters.

Returns
double Distance in meters

◆ inch() [1/2]

double JSN_SR04_Gen3::Distance::inch ( ) const
inline

Get the value of the Distance in inches.

Returns
double Distance in inches

◆ inch() [2/2]

void JSN_SR04_Gen3::Distance::inch ( double  inch)
inline

Set the distance in inches.

Parameters
inchDistance in inches (double floating point)

Internally, the distance is stored in meters, but this sets the value in inches. You can mix-and-match, for example you can get the distance in centimeters after setting it in inches.

◆ mm() [1/2]

double JSN_SR04_Gen3::Distance::mm ( ) const
inline

Get the value of the Distance in millimeters.

Returns
double Distance in millimeters

◆ mm() [2/2]

void JSN_SR04_Gen3::Distance::mm ( double  mm)
inline

Set the distance in millimeter.

Parameters
mmDistance in millimeters (double floating point)

Internally, the distance is stored in meters, but this sets the value in millimeters. You can mix-and-match, for example you can get the distance in inches after setting it in millimeters.

◆ operator=()

Distance & JSN_SR04_Gen3::Distance::operator= ( const Distance value)
inline

Copy the distance value from another Distance object.

Parameters
valueThe object to copy the distance from
Returns
Distance& Return this object, so you can chain multiple assignments

◆ setDistanceM()

void JSN_SR04_Gen3::Distance::setDistanceM ( double  distanceM)
inline

Set the Distance in meters.

Parameters
distanceMthe distance in meters to set

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