From 928bb1f2efe89749babfe135cad4cced4c557212 Mon Sep 17 00:00:00 2001 From: Louis Thiery Date: Sat, 13 Apr 2024 11:39:24 -0700 Subject: [PATCH] fix display of PacketUp --- src/packet.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/packet.rs b/src/packet.rs index 13f370c3..fcb491d7 100644 --- a/src/packet.rs +++ b/src/packet.rs @@ -50,10 +50,16 @@ impl From 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,