roo_quantity
API Documentation for roo_quantity
Loading...
Searching...
No Matches
volume_flow_rate.cpp
Go to the documentation of this file.
2
3namespace roo_quantity {
4namespace {
5
6void VolumeFlowRateToString(const VolumeFlowRate& val, char* out, int maxlen) {
7 if (val.isUnknown()) {
8 strncpy(out, "? m³/s", maxlen);
9 } else {
10 const char* format;
11 float num;
13 format = "%g m³/s";
14 num = val.inCubicMetersPerSecond();
15 } else if (val > VolumeFlowRateInLitersPerSecond(1.0f)) {
16 format = "%g L/s";
17 num = val.inLitersPerSecond();
18 } else {
19 format = "%g mL/s";
20 num = val.inMillilitersPerSecond();
21 }
22 snprintf(out, maxlen, format, num);
23 }
24}
25
26} // namespace
27
28#if defined(ESP32) || defined(ESP8266) || defined(__linux__)
29
30std::string VolumeFlowRate::asString() const {
31 char out[16];
32 VolumeFlowRateToString(*this, out, 16);
33 return out;
34}
35
36#endif
37
38#if defined(ARDUINO)
39
40String VolumeFlowRate::asArduinoString() const {
41 char out[16];
42 VolumeFlowRateToString(*this, out, 16);
43 return out;
44}
45
46#endif
47
48roo_logging::Stream& operator<<(roo_logging::Stream& os, const VolumeFlowRate& val) {
49 char out[16];
50 VolumeFlowRateToString(val, out, 16);
51 os << out;
52 return os;
53}
54
55} // namespace roo_quantity
Representation of volume flow rate, internally stored as floating-point cubic meters per second.
For convenience conversion from roo_time::Duration.
Definition area.cpp:3
roo_logging::Stream & operator<<(roo_logging::Stream &os, const Area &val)
Definition area.cpp:57
VolumeFlowRate VolumeFlowRateInCubicMetersPerSecond(float volume_flow_rate)
Returns a volume flow rate object equivalent to the specified volume flow rate expressed in cubic met...
VolumeFlowRate VolumeFlowRateInLitersPerSecond(float volume_flow_rate)
Returns a volume flow rate object equivalent to the specified volume flow rate expressed in liters pe...