Back to godoc.org

Package lsm303

v0.0.0-...-d3d8c0c
Latest Go to latest

The latest major version is .

Published: May 8, 2017 | License: MIT | Module: github.com/kidoman/embd

Overview

Package lsm303 allows interfacing with the LSM303 magnetometer.

Index

Constants

const (
	MagHz75         = 0x00 // ODR = 0.75 Hz
	Mag1Hz5         = 0x04 // ODR = 1.5 Hz
	Mag3Hz          = 0x08 // ODR = 3 Hz
	Mag7Hz5         = 0x0C // ODR = 7.5 Hz
	Mag15Hz         = 0x10 // ODR = 15 Hz
	Mag30Hz         = 0x14 // ODR = 30 Hz
	Mag75Hz         = 0x18 // ODR = 75 Hz
	MagNormal       = 0x00 // Normal mode
	MagPositiveBias = 0x01 // Positive bias mode
	MagNegativeBias = 0x02 // Negative bias mode

	MagCRADefault = Mag15Hz | MagNormal // 15 Hz and normal mode is the default

	MagContinuous = 0x00 // Continuous conversion mode
	MagSingle     = 0x01 // Single conversion mode
	MagSleep      = 0x03 // Sleep mode

	MagMRDefault = MagContinuous // Continuous conversion is the default

)

type LSM303

type LSM303 struct {
	Bus  embd.I2CBus
	Poll int
	// contains filtered or unexported fields
}

LSM303 represents a LSM303 magnetometer.

func New

func New(bus embd.I2CBus) *LSM303

New creates a new LSM303 interface. The bus variable controls the I2C bus used to communicate with the device.

func (*LSM303) Close

func (d *LSM303) Close() error

Close the sensor data acquisition loop and put the LSM303 into sleep mode.

func (*LSM303) Heading

func (d *LSM303) Heading() (float64, error)

Heading returns the current heading [0, 360).

func (*LSM303) Run

func (d *LSM303) Run() error

Run starts the sensor data acquisition loop.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier