Round measures to their significant bits, remove debug statements
This commit is contained in:
parent
eedf62e304
commit
cc63f34e9e
@ -29,11 +29,13 @@ struct Data {
|
||||
|
||||
impl Data {
|
||||
fn from_pkt(addr: Address, b: &[u8]) -> Data {
|
||||
eprintln!("Packet {:?}", b);
|
||||
|
||||
let round = |v: f32| (v*100.0).round() / 100.0;
|
||||
|
||||
Data {
|
||||
addr,
|
||||
temperature: (u16::from_le_bytes([b[2], b[3]]) as f32) * 175.0 / 65535.0 - 45.0,
|
||||
humidity: (u16::from_le_bytes([b[4], b[5]]) as f32) * 100.0 / 65535.0,
|
||||
temperature: round((u16::from_le_bytes([b[2], b[3]]) as f32) * 175.0 / 65535.0 - 45.0),
|
||||
humidity: round((u16::from_le_bytes([b[4], b[5]]) as f32) * 100.0 / 65535.0),
|
||||
co2: u16::from_le_bytes([b[6], b[7]]),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user