Documentation ¶
Index ¶
- type DeviceSPI
- func (d *DeviceSPI) Configure() error
- func (d *DeviceSPI) Connected() bool
- func (d *DeviceSPI) ReadAcceleration() (x int32, y int32, z int32, err error)
- func (d *DeviceSPI) ReadRotation() (x int32, y int32, z int32, err error)
- func (d *DeviceSPI) ReadTemperature() (temperature int32, err error)
- func (d *DeviceSPI) Reset() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeviceSPI ¶
type DeviceSPI struct { // Chip select pin CSB machine.Pin // SPI bus (requires chip select to be usable). Bus drivers.SPI // contains filtered or unexported fields }
DeviceSPI is the SPI interface to a BMI160 accelerometer/gyroscope. There is also an I2C interface, but it is not yet supported.
func NewSPI ¶
NewSPI returns a new device driver. The pin and SPI interface are not touched, provide a fully configured SPI object and call Configure to start using this device.
func (*DeviceSPI) Configure ¶
Configure configures the BMI160 for use. It configures the CSB pin and configures the BMI160, but it does not configure the SPI interface (it is assumed to be up and running).
func (*DeviceSPI) Connected ¶
Connected check whether the device appears to be properly connected. It reads the CHIPID, which must be 0xD1 for the BMI160.
func (*DeviceSPI) ReadAcceleration ¶
ReadAcceleration reads the current acceleration from the device and returns it in µg (micro-gravity). When one of the axes is pointing straight to Earth and the sensor is not moving the returned value will be around 1000000 or -1000000.
func (*DeviceSPI) ReadRotation ¶
ReadRotation reads the current rotation from the device and returns it in µ°/s (micro-degrees/sec). This means that if you were to do a complete rotation along one axis and while doing so integrate all values over time, you would get a value close to 360000000.
func (*DeviceSPI) ReadTemperature ¶
ReadTemperature returns the temperature in celsius milli degrees (°C/1000).