embd: github.com/kidoman/embd/sensor/lsm303 Index | Files

package lsm303

import "github.com/kidoman/embd/sensor/lsm303"

Package lsm303 allows interfacing with the LSM303 magnetometer.

Index

Package Files

lsm303.go

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 Uses

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

LSM303 represents a LSM303 magnetometer.

func New Uses

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 Uses

func (d *LSM303) Close() error

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

func (*LSM303) Heading Uses

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

Heading returns the current heading [0, 360).

func (*LSM303) Run Uses

func (d *LSM303) Run() error

Run starts the sensor data acquisition loop.

Package lsm303 imports 5 packages (graph) and is imported by 2 packages. Updated 2016-08-02. Refresh now. Tools for package owners.