mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-05-05 08:15:11 -04:00
Extract Temperature, Pressure into units header.
This commit is contained in:
parent
45a8759d7b
commit
798b5eb972
2 changed files with 87 additions and 52 deletions
|
@ -31,6 +31,10 @@
|
|||
|
||||
#include "optional.hpp"
|
||||
|
||||
#include "units.hpp"
|
||||
using units::Temperature;
|
||||
using units::Pressure;
|
||||
|
||||
namespace tpms {
|
||||
|
||||
class TransponderID {
|
||||
|
@ -54,56 +58,6 @@ private:
|
|||
uint32_t id_;
|
||||
};
|
||||
|
||||
class Pressure {
|
||||
public:
|
||||
constexpr Pressure(
|
||||
) : kpa_ { 0 }
|
||||
{
|
||||
}
|
||||
|
||||
constexpr Pressure(
|
||||
const int32_t kilopascal
|
||||
) : kpa_ { static_cast<int16_t>(kilopascal) }
|
||||
{
|
||||
}
|
||||
|
||||
int kilopascal() const {
|
||||
return kpa_;
|
||||
}
|
||||
|
||||
int psi() const {
|
||||
return static_cast<int32_t>(kpa_) * 1000 / 6895;
|
||||
}
|
||||
|
||||
private:
|
||||
int16_t kpa_;
|
||||
};
|
||||
|
||||
class Temperature {
|
||||
public:
|
||||
constexpr Temperature(
|
||||
) : c_ { 0 }
|
||||
{
|
||||
}
|
||||
|
||||
constexpr Temperature(
|
||||
const int32_t celsius
|
||||
) : c_ { static_cast<int16_t>(celsius) }
|
||||
{
|
||||
}
|
||||
|
||||
int celsius() const {
|
||||
return c_;
|
||||
}
|
||||
|
||||
int fahrenheit() const {
|
||||
return (c_ * 9 / 5) + 32;
|
||||
}
|
||||
|
||||
private:
|
||||
int16_t c_;
|
||||
};
|
||||
|
||||
class Reading {
|
||||
public:
|
||||
enum Type {
|
||||
|
@ -208,8 +162,8 @@ struct TPMSRecentEntry {
|
|||
|
||||
size_t received_count { 0 };
|
||||
|
||||
Optional<tpms::Pressure> last_pressure;
|
||||
Optional<tpms::Temperature> last_temperature;
|
||||
Optional<Pressure> last_pressure;
|
||||
Optional<Temperature> last_temperature;
|
||||
|
||||
TPMSRecentEntry(
|
||||
const Key& key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue