Skip to content

Commit

Permalink
fix display of PacketUp
Browse files Browse the repository at this point in the history
  • Loading branch information
lthiery committed Apr 13, 2024
1 parent 1d69023 commit 928bb1f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ impl From<PacketRouterPacketDownV1> for PacketDown {

impl fmt::Display for PacketUp {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut decimal = self.0.frequency.to_string();
// insert period before the last 6 digits
decimal.insert(decimal.len() - 6, '.');
// remove trailing 0's
decimal = decimal.trim_end_matches('0').to_string();

f.write_fmt(format_args!(
"@{} us, {:.2} MHz, {:?}, snr: {}, rssi: {}, len: {}",
"@{} us, {} MHz, {:?}, snr: {}, rssi: {}, len: {}",
self.0.timestamp,
self.0.frequency,
decimal,
self.0.datarate(),
self.0.snr,
self.0.rssi,
Expand Down

0 comments on commit 928bb1f

Please sign in to comment.