diff --git a/main/sensors.go b/main/sensors.go index 2227a825..ad2df254 100644 --- a/main/sensors.go +++ b/main/sensors.go @@ -33,7 +33,7 @@ var ( ) func initI2CSensors() { - i2cbus = embd.NewI2CBus(1) + i2cbus = embd.NewI2CBus(0) go pollSensors() go sensorAttitudeSender() @@ -124,7 +124,7 @@ func tempAndPressureSender() { } func initIMU() (ok bool) { - imu, err := sensors.NewMPU9250() + imu, err := sensors.NewMPU9250(&i2cbus) if err == nil { myIMUReader = imu return true diff --git a/sensors/mpu9250.go b/sensors/mpu9250.go index 6ba9e003..f32d3ab0 100644 --- a/sensors/mpu9250.go +++ b/sensors/mpu9250.go @@ -19,14 +19,14 @@ type MPU9250 struct { // NewMPU9250 returns an instance of the MPU9250 IMUReader, connected to an // MPU9250 attached on the I2C bus with either valid address. -func NewMPU9250() (*MPU9250, error) { +func NewMPU9250(i2cbus *embd.I2CBus) (*MPU9250, error) { var ( m MPU9250 mpu *mpu9250.MPU9250 err error ) - mpu, err = mpu9250.NewMPU9250(gyroRange, accelRange, updateFreq, true, false) + mpu, err = mpu9250.NewMPU9250(i2cbus, gyroRange, accelRange, updateFreq, true, false) if err != nil { return nil, err }