// Return a new Device func NewLSM303ACCEL() (bp *LSM303ACCEL, err error) { bp = new(LSM303ACCEL) bp.bus, err = i2c.Bus(1) // Turn it on, enable all 3 axis err = bp.bus.WriteByte(LSM303ACCEL_ADDR, LSM303ACCEL_CTRL_REG1, 0x27) return }
// Return a new Device func NewL3GD20() (bp *L3GD20, err error) { bp = new(L3GD20) bp.bus, err = i2c.Bus(1) bp.dpsRange = L3GD20_RANGE_250DPS // Turn it on, enable all 3 axis err = bp.bus.WriteByte(L3GD20_ADDR, L3GD20_CTRL_REG1, 0x0F) return }
// Return a new Device func NewLSM303MAG() (bp *LSM303MAG, err error) { bp = new(LSM303MAG) bp.bus, err = i2c.Bus(1) if err == nil { // Turn it on err = bp.bus.WriteByte(LSM303MAG_ADDR, LSM303MAG_MR_REG, 0x00) if err == nil { // Set the gain to a known level err = bp.SetGain(LSM303MAG_GAIN_1_3) } } return }