Skip to content

Commit

Permalink
Use 8192 & 32768 to scale
Browse files Browse the repository at this point in the history
  • Loading branch information
little-arhat committed Nov 12, 2022
1 parent d669b83 commit d774968
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ pub enum MagScale {
impl MagScale {
pub(crate) fn resolution(&self) -> f32 {
match self {
MagScale::_14BITS => 10. * 4912. / 8190.,
MagScale::_16BITS => 10. * 4912. / 32760.0,
MagScale::_14BITS => 10. * 4912. / 8192.,
MagScale::_16BITS => 10. * 4912. / 32768.0,
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,11 @@ impl<E, DEV> Mpu9250<DEV, Marg>
AK8963::init(&mut self.dev, delay)?;
delay.delay_ms(10);
// First extract the factory calibration for each magnetometer axis
/// Power down
AK8963::write(&mut self.dev, ak8963::Register::CNTL, 0x00)?;
delay.delay_ms(10);

/// Fuse ROM access mode
AK8963::write(&mut self.dev, ak8963::Register::CNTL, 0x0F)?;
delay.delay_ms(20);
let mag_x_bias = AK8963::read(&mut self.dev, ak8963::Register::ASAX)?;
Expand All @@ -722,6 +724,7 @@ impl<E, DEV> Mpu9250<DEV, Marg>
self.mag_sensitivity_adjustments = [f32(mag_x_bias - 128) / 256. + 1.,
f32(mag_y_bias - 128) / 256. + 1.,
f32(mag_z_bias - 128) / 256. + 1.];
/// Power down magnetometer
AK8963::write(&mut self.dev, ak8963::Register::CNTL, 0x00)?;
delay.delay_ms(10);
// Set magnetometer data resolution and sample ODR
Expand Down

0 comments on commit d774968

Please sign in to comment.