Skip to content

Commit

Permalink
Merge pull request tkeksa#13 from us-irs/fix-temp-val-to-float
Browse files Browse the repository at this point in the history
Fix Temperature Raw Value To Float
  • Loading branch information
tkeksa authored Oct 1, 2024
2 parents 22a6751 + 09a52d3 commit 4f00b90
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 @@ -565,8 +565,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 4f00b90

Please sign in to comment.