roo_quantity
API Documentation for roo_quantity
Loading...
Searching...
No Matches
work.cpp
Go to the documentation of this file.
1#include "roo_quantity/work.h"
2
3#include "roo_quantity/si.h"
4
5namespace roo_quantity {
6namespace {
7
8void WorkToString(const Work& val, char* out, int maxlen) {
9 FormatSimpleSiValue(val.inJoules(), "J", out, maxlen);
10}
11
12} // namespace
13
14#if defined(ESP32) || defined(ESP8266) || defined(__linux__)
15
16std::string Work::asString() const {
17 char out[16];
18 WorkToString(*this, out, 16);
19 return out;
20}
21
22#endif
23
24#if defined(ARDUINO)
25
26String Work::asArduinoString() const {
27 char out[16];
28 WorkToString(*this, out, 16);
29 return out;
30}
31
32#endif
33
34roo_logging::Stream& operator<<(roo_logging::Stream& os, const Work& val) {
35 char out[16];
36 WorkToString(val, out, 16);
37 os << out;
38 return os;
39}
40
41} // namespace roo_quantity
Representation of work, internally stored as floating-point Joules.
Definition work.h:19
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
void FormatSimpleSiValue(float val, const char *base_unit, char *out, int maxlen)
Formats a value with an SI prefix and base unit.
Definition si.cpp:8