extern crate linux_embedded_hal as hal; use bmi160::{AccelerometerPowerMode, Bmi160, GyroscopePowerMode, SensorSelector, SlaveAddr}; fn main() { let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); let address = SlaveAddr::default(); let mut imu = Bmi160::new_with_i2c(dev, address); imu.set_accel_power_mode(AccelerometerPowerMode::Normal) .unwrap(); imu.set_gyro_power_mode(GyroscopePowerMode::Normal).unwrap(); loop { let data = imu.data(SensorSelector::new().accel().gyro()).unwrap(); let accel = data.accel.unwrap(); let gyro = data.gyro.unwrap(); println!( "Accelerometer: x {:5} y {:5} z {:5}, \ Gyroscope: x {:5} y {:5} z {:5}", accel.x, accel.y, accel.z, gyro.x, gyro.y, gyro.z ); } }