JSN-SR04_Gen3_RK
|
Utility class for holding a distance. More...
#include <JSN-SR04_Gen3_RK.h>
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... | |
Distance & | operator= (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. | |
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).
|
inline |
Construct a new Distance object with a distance in meters.
valueM | distance in meters (double floating point) |
|
inline |
|
inline |
|
inline |
Set the distance in centimeters.
cm | Distance 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.
|
inline |
|
inline |
|
inline |
Set the distance in inches.
inch | Distance 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.
|
inline |
|
inline |
Set the distance in millimeter.
mm | Distance 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.
|
inline |
Set the Distance in meters.
distanceM | the distance in meters to set |