clean, comments
This commit is contained in:
parent
7bbeac63fd
commit
267fb85206
2 changed files with 6 additions and 48 deletions
|
@ -1,48 +0,0 @@
|
||||||
use mpu6050::*;
|
|
||||||
use linux_embedded_hal::{I2cdev, Delay};
|
|
||||||
use i2cdev::linux::LinuxI2CError;
|
|
||||||
|
|
||||||
fn main() -> Result<(), Error<LinuxI2CError>> {
|
|
||||||
let i2c = I2cdev::new("/dev/i2c-1")
|
|
||||||
.map_err(Error::I2c)?;
|
|
||||||
|
|
||||||
let delay = Delay;
|
|
||||||
|
|
||||||
let mut mpu = Mpu6050::new(i2c, delay);
|
|
||||||
mpu.init()?;
|
|
||||||
//mpu.soft_calib(200)?;
|
|
||||||
|
|
||||||
loop {
|
|
||||||
// get roll and pitch estimate
|
|
||||||
match mpu.get_acc_angles() {
|
|
||||||
Ok(r) => {
|
|
||||||
println!("r/p: {:?}", r);
|
|
||||||
},
|
|
||||||
Err(_) => {} ,
|
|
||||||
}
|
|
||||||
|
|
||||||
// get temp
|
|
||||||
match mpu.get_temp() {
|
|
||||||
Ok(r) => {
|
|
||||||
println!("temp: {}c", r);
|
|
||||||
},
|
|
||||||
Err(_) => {} ,
|
|
||||||
}
|
|
||||||
|
|
||||||
// get gyro data, scaled with sensitivity
|
|
||||||
match mpu.get_gyro() {
|
|
||||||
Ok(r) => {
|
|
||||||
println!("gyro: {:?}", r);
|
|
||||||
},
|
|
||||||
Err(_) => {} ,
|
|
||||||
}
|
|
||||||
|
|
||||||
// get accelerometer data, scaled with sensitivity
|
|
||||||
match mpu.get_acc() {
|
|
||||||
Ok(r) => {
|
|
||||||
println!("acc: {:?}", r);
|
|
||||||
},
|
|
||||||
Err(_) => {} ,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,11 +16,17 @@ use embedded_hal::{
|
||||||
/// Used for bias calculation of chip in mpu::soft_calib
|
/// Used for bias calculation of chip in mpu::soft_calib
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Bias {
|
struct Bias {
|
||||||
|
/// accelerometer x axis bias
|
||||||
ax: f32,
|
ax: f32,
|
||||||
|
/// accelerometer y axis bias
|
||||||
ay: f32,
|
ay: f32,
|
||||||
|
/// accelerometer z axis bias
|
||||||
az: f32,
|
az: f32,
|
||||||
|
/// gyro x axis bias
|
||||||
gx: f32,
|
gx: f32,
|
||||||
|
/// gyro y axis bias
|
||||||
gy: f32,
|
gy: f32,
|
||||||
|
/// gyro z axis bias
|
||||||
gz: f32,
|
gz: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue