Skip to content

Commit

Permalink
Fix temperature value to float conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Jun 24, 2024
1 parent 030919b commit 09a52d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ impl<I2C: I2c> Lis2dh12<I2C> {
pub fn get_temp_outf(&mut self) -> Result<f32, Error<I2C::Error>> {
let (out_h, out_l) = self.get_temp_out()?;
// 10-bit resolution
let value = (i16(out_h) << 2) | i16(out_l >> 6);
Ok(f32(value) * 0.25)
let value = (i16(out_h) << 8) | i16(out_l);
Ok(25.0 + f32(value) / 256.0)
}

/// `REFERENCE` register
Expand Down

0 comments on commit 09a52d3

Please sign in to comment.