diff --git a/firmware/application/tpms_app.cpp b/firmware/application/tpms_app.cpp index d6e1ef9f..09f5fc1a 100644 --- a/firmware/application/tpms_app.cpp +++ b/firmware/application/tpms_app.cpp @@ -47,6 +47,10 @@ std::string temperature(Temperature temperature) { return to_string_dec_int(temperature.celsius(), 3); } +std::string flags(Flags flags) { + return to_string_hex(flags, 2); +} + } /* namespace format */ } /* namespace tpms */ @@ -72,16 +76,20 @@ void TPMSRecentEntry::update(const tpms::Reading& reading) { if( reading.temperature().is_valid() ) { last_temperature = reading.temperature(); } + if( reading.flags().is_valid() ) { + last_flags = reading.flags(); + } } namespace ui { -static const std::array, 5> tpms_columns { { +static const std::array, 6> tpms_columns { { { "Tp", 2 }, { "ID", 8 }, { "kPa", 3 }, { "C", 3 }, { "Cnt", 3 }, + { "Fl", 2 }, } }; template<> @@ -133,6 +141,12 @@ void RecentEntriesView::draw( line += " " + to_string_dec_uint(entry.received_count, 3); } + if( entry.last_flags.is_valid() ) { + line += " " + tpms::format::flags(entry.last_flags.value()); + } else { + line += " " " "; + } + line.resize(target_rect.width() / 8, ' '); painter.draw_string(target_rect.pos, draw_style, line); } diff --git a/firmware/application/tpms_app.hpp b/firmware/application/tpms_app.hpp index e4f00b7a..8ed0a50e 100644 --- a/firmware/application/tpms_app.hpp +++ b/firmware/application/tpms_app.hpp @@ -53,6 +53,7 @@ struct TPMSRecentEntry { Optional last_pressure; Optional last_temperature; + Optional last_flags; TPMSRecentEntry( const Key& key diff --git a/firmware/common/tpms_packet.cpp b/firmware/common/tpms_packet.cpp index 0fc57dd3..68b80c1e 100644 --- a/firmware/common/tpms_packet.cpp +++ b/firmware/common/tpms_packet.cpp @@ -74,7 +74,9 @@ Optional Packet::reading(const SignalType signal_type) const { return Reading { Reading::Type::Schrader, reader_.read(3, 24), - Pressure { static_cast(reader_.read(27, 8)) } + Pressure { static_cast(reader_.read(27, 8)) * 4 / 3 }, + { }, + Flags { (flags << 4) | checksum } }; } diff --git a/firmware/common/tpms_packet.hpp b/firmware/common/tpms_packet.hpp index 57d8d929..34c80397 100644 --- a/firmware/common/tpms_packet.hpp +++ b/firmware/common/tpms_packet.hpp @@ -37,6 +37,8 @@ using units::Pressure; namespace tpms { +using Flags = uint8_t; + enum SignalType : uint32_t { FLM = 1, Schrader = 2, @@ -92,11 +94,13 @@ public: Type type, TransponderID id, Optional pressure = { }, - Optional temperature = { } + Optional temperature = { }, + Optional flags = { } ) : type_ { type }, id_ { id }, pressure_ { pressure }, - temperature_ { temperature } + temperature_ { temperature }, + flags_ { flags } { } @@ -116,11 +120,16 @@ public: return temperature_; } + Optional flags() const { + return flags_; + } + private: Type type_ { Type::None }; TransponderID id_ { 0 }; Optional pressure_ { }; Optional temperature_ { }; + Optional flags_ { }; }; class Packet {