6void LengthToString(Length val,
char* out,
int maxlen) {
8 strncpy(out,
"? m", maxlen);
11 const char* sign =
"";
13 if (val.inMeters() == 0.0f) {
14 snprintf(out, maxlen,
"0 m");
17 if (val.inMeters() < 0) {
23 num = val.inKilometers();
29 num = val.inCentimeters();
32 num = val.inMillimeters();
35 num = val.inMicrometers();
38 num = val.inNanometers();
40 snprintf(out, maxlen, format, sign, num);
46#if defined(ESP32) || defined(ESP8266) || defined(__linux__)
48std::string Length::asString()
const {
50 LengthToString(*
this, out, 16);
58String Length::asArduinoString()
const {
60 LengthToString(*
this, out, 16);
68 LengthToString(val, out, 16);
Representation of length, internally stored as floating-point meters.
For convenience conversion from roo_time::Duration.
Length LengthInMeters(float length)
Returns a length object equivalent to the specified length expressed in meters.
roo_logging::Stream & operator<<(roo_logging::Stream &os, const Area &val)
Length LengthInMillimeters(float length)
Returns a length object equivalent to the specified length expressed in millimeters.
Length LengthInMicrometers(float length)
Returns a length object equivalent to the specified length expressed in micrometers.
Length LengthInCentimeters(float length)
Returns a length object equivalent to the specified length expressed in centimeters.