6#include "roo_logging.h"
8#if defined(ESP32) || defined(ESP8266) || defined(__linux__)
22 Mass() : mass_(std::nanf(
"")) {}
25 float inTons()
const {
return mass_ * 0.001f; }
33 float inGrams()
const {
return mass_ * 1000.0f; }
42 float inPounds()
const {
return mass_ * 2.2046226218f; }
48 bool isUnknown()
const {
return std::isnan(mass_); }
63 mass_ += other.
inKg();
68 mass_ -= other.
inKg();
82#if defined(ESP32) || defined(ESP8266) || defined(__linux__)
84 std::string asString()
const;
88 String asArduinoString()
const;
96 explicit Mass(
float mass) : mass_(mass) {}
132 return MassInKg(mass * 0.000000001f);
155roo_logging::Stream&
operator<<(roo_logging::Stream& os,
const Mass& val);
Representation of mass, internally stored as floating-point kilograms.
bool isUnknown() const
Returns whether the object represents an unknown mass.
Mass & operator+=(const Mass &other)
bool operator!=(const Mass &other) const
float inTons() const
Returns the mass in metric tonnes.
friend Mass UnknownMass()
Returns a mass object representing an unknown mass.
float inMilligrams() const
Returns the mass in milligrams.
Mass()
Creates a mass object representing an 'unknown' mass.
Mass & operator-=(const Mass &other)
Mass & operator*=(float multi)
bool operator<=(const Mass &other) const
bool operator>=(const Mass &other) const
float inPounds() const
Returns the mass in pounds.
float inMicrograms() const
Returns the mass in micrograms.
friend Mass MassInKilograms(float)
Returns a mass object equivalent to the specified mass expressed in kilograms.
float inLbs() const
Returns the mass in pounds.
float inKilograms() const
Returns the mass in kilograms.
Mass & operator/=(float div)
float inGrams() const
Returns the mass in grams.
bool operator<(const Mass &other) const
bool operator>(const Mass &other) const
bool operator==(const Mass &other) const
For convenience conversion from roo_time::Duration.
roo_logging::Stream & operator<<(roo_logging::Stream &os, const Area &val)
Mass MassInLbs(float mass)
Mass UnknownMass()
Returns a mass object representing an unknown mass.
Area operator+(Area a, Area b)
Area operator-(Area a, Area b)
Mass MassInKg(float mass)
Returns a mass object equivalent to the specified mass expressed in kilograms.
Mass MassInMilligrams(float mass)
Returns a mass object equivalent to the specified mass expressed in milligrams.
Mass MassInGrams(float mass)
Returns a mass object equivalent to the specified mass expressed in grams.
Mass MassInPounds(float mass)
Returns a mass object equivalent to the specified mass expressed in pounds.
Mass MassInTons(float mass)
Returns a mass object equivalent to the specified mass expressed in metric tons.
Area operator/(Area a, float b)
Area operator*(Area a, float b)
Mass MassInMicrograms(float mass)
Returns a mass object equivalent to the specified mass expressed in micrograms.
Mass MassInKilograms(float mass)
Returns a mass object equivalent to the specified mass expressed in kilograms.