6void PressureToString(Pressure val,
char* out,
int maxlen) {
8 strncpy(out,
"? Pa", maxlen);
11 const char* sign =
"";
13 if (val.inPascals() == 0.0f) {
14 snprintf(out, maxlen,
"0 Pa");
17 if (val.inPascals() < 0) {
23 num = val.inGigaPascals();
26 num = val.inMegaPascals();
38 num = val.inKiloPascals();
41 num = val.inPascals();
44 num = val.inMilliPascals();
47 num = val.inMicroPascals();
49 snprintf(out, maxlen, format, sign, num);
55#if defined(ESP32) || defined(ESP8266) || defined(__linux__)
57std::string Pressure::asString()
const {
59 PressureToString(*
this, out, 16);
67String Pressure::asArduinoString()
const {
69 PressureToString(*
this, out, 16);
77 PressureToString(val, out, 16);
Representation of pressure, internally stored as floating-point Pascals.
For convenience conversion from roo_time::Duration.
Pressure PressureInKiloPascals(float pressure)
Returns a pressure object equivalent to the specified pressure expressed in kiloPascals.
roo_logging::Stream & operator<<(roo_logging::Stream &os, const Area &val)
Pressure PressureInGigaPascals(float pressure)
Returns a pressure object equivalent to the specified pressure expressed in GigaPascals.
Pressure PressureInBars(float pressure)
Returns a pressure object equivalent to the specified pressure expressed in bars.
Pressure PressureInPascals(float pressure)
Returns a pressure object equivalent to the specified pressure expressed in Pascals.
Pressure PressureInMegaPascals(float pressure)
Returns a pressure object equivalent to the specified pressure expressed in MegaPascals.
Pressure PressureInMilliPascals(float pressure)
Returns a pressure object equivalent to the specified pressure expressed in milliPascals.