mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-13 09:03:37 +00:00
TPMS: Quick implementation of "flags" column.
For now, shows only for Schrader OOK packets: top (left) nibble is function code, bottom nibble has two-bit checksum.
This commit is contained in:
parent
40859444fe
commit
05df04df7e
@ -47,6 +47,10 @@ std::string temperature(Temperature temperature) {
|
|||||||
return to_string_dec_int(temperature.celsius(), 3);
|
return to_string_dec_int(temperature.celsius(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string flags(Flags flags) {
|
||||||
|
return to_string_hex(flags, 2);
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace format */
|
} /* namespace format */
|
||||||
|
|
||||||
} /* namespace tpms */
|
} /* namespace tpms */
|
||||||
@ -72,16 +76,20 @@ void TPMSRecentEntry::update(const tpms::Reading& reading) {
|
|||||||
if( reading.temperature().is_valid() ) {
|
if( reading.temperature().is_valid() ) {
|
||||||
last_temperature = reading.temperature();
|
last_temperature = reading.temperature();
|
||||||
}
|
}
|
||||||
|
if( reading.flags().is_valid() ) {
|
||||||
|
last_flags = reading.flags();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
static const std::array<std::pair<std::string, size_t>, 5> tpms_columns { {
|
static const std::array<std::pair<std::string, size_t>, 6> tpms_columns { {
|
||||||
{ "Tp", 2 },
|
{ "Tp", 2 },
|
||||||
{ "ID", 8 },
|
{ "ID", 8 },
|
||||||
{ "kPa", 3 },
|
{ "kPa", 3 },
|
||||||
{ "C", 3 },
|
{ "C", 3 },
|
||||||
{ "Cnt", 3 },
|
{ "Cnt", 3 },
|
||||||
|
{ "Fl", 2 },
|
||||||
} };
|
} };
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
@ -133,6 +141,12 @@ void RecentEntriesView<TPMSRecentEntries>::draw(
|
|||||||
line += " " + to_string_dec_uint(entry.received_count, 3);
|
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, ' ');
|
line.resize(target_rect.width() / 8, ' ');
|
||||||
painter.draw_string(target_rect.pos, draw_style, line);
|
painter.draw_string(target_rect.pos, draw_style, line);
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ struct TPMSRecentEntry {
|
|||||||
|
|
||||||
Optional<Pressure> last_pressure;
|
Optional<Pressure> last_pressure;
|
||||||
Optional<Temperature> last_temperature;
|
Optional<Temperature> last_temperature;
|
||||||
|
Optional<tpms::Flags> last_flags;
|
||||||
|
|
||||||
TPMSRecentEntry(
|
TPMSRecentEntry(
|
||||||
const Key& key
|
const Key& key
|
||||||
|
@ -74,7 +74,9 @@ Optional<Reading> Packet::reading(const SignalType signal_type) const {
|
|||||||
return Reading {
|
return Reading {
|
||||||
Reading::Type::Schrader,
|
Reading::Type::Schrader,
|
||||||
reader_.read(3, 24),
|
reader_.read(3, 24),
|
||||||
Pressure { static_cast<int>(reader_.read(27, 8)) }
|
Pressure { static_cast<int>(reader_.read(27, 8)) * 4 / 3 },
|
||||||
|
{ },
|
||||||
|
Flags { (flags << 4) | checksum }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ using units::Pressure;
|
|||||||
|
|
||||||
namespace tpms {
|
namespace tpms {
|
||||||
|
|
||||||
|
using Flags = uint8_t;
|
||||||
|
|
||||||
enum SignalType : uint32_t {
|
enum SignalType : uint32_t {
|
||||||
FLM = 1,
|
FLM = 1,
|
||||||
Schrader = 2,
|
Schrader = 2,
|
||||||
@ -92,11 +94,13 @@ public:
|
|||||||
Type type,
|
Type type,
|
||||||
TransponderID id,
|
TransponderID id,
|
||||||
Optional<Pressure> pressure = { },
|
Optional<Pressure> pressure = { },
|
||||||
Optional<Temperature> temperature = { }
|
Optional<Temperature> temperature = { },
|
||||||
|
Optional<Flags> flags = { }
|
||||||
) : type_ { type },
|
) : type_ { type },
|
||||||
id_ { id },
|
id_ { id },
|
||||||
pressure_ { pressure },
|
pressure_ { pressure },
|
||||||
temperature_ { temperature }
|
temperature_ { temperature },
|
||||||
|
flags_ { flags }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,11 +120,16 @@ public:
|
|||||||
return temperature_;
|
return temperature_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Optional<Flags> flags() const {
|
||||||
|
return flags_;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type type_ { Type::None };
|
Type type_ { Type::None };
|
||||||
TransponderID id_ { 0 };
|
TransponderID id_ { 0 };
|
||||||
Optional<Pressure> pressure_ { };
|
Optional<Pressure> pressure_ { };
|
||||||
Optional<Temperature> temperature_ { };
|
Optional<Temperature> temperature_ { };
|
||||||
|
Optional<Flags> flags_ { };
|
||||||
};
|
};
|
||||||
|
|
||||||
class Packet {
|
class Packet {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user