bma42x

package
v0.0.0-...-0087ba1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package bma42x provides a driver for the BMA421 and BMA425 accelerometer chips.

Here is a reasonably good datasheet: https://datasheet.lcsc.com/lcsc/1912111437_Bosch-Sensortec-BMA425_C437656.pdf

This driver was originally written for the PineTime, using the datasheet as a guide. There is an open source C driver provided by Bosch, but unfortunately it needs some small modifications to work with other chips (most importantly, the "config file"). The InfiniTime and Wasp-OS drivers for this accelerometer have also been used to figure out some driver details (especially step counting).

Index

Constants

View Source
const Address = 0x18 // BMA421/BMA425 address
View Source
const (
	FeatureStepCounting = 1 << iota
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Which devices to support (OR the device types together as needed).
	Device DeviceType

	// Which features to enable. With Features == 0, only the accelerometer will
	// be enabled.
	Features Features
}

type Device

type Device struct {
	// contains filtered or unexported fields
}

func NewI2C

func NewI2C(i2c drivers.I2C, address uint8) *Device

func (*Device) Acceleration

func (d *Device) Acceleration() (x, y, z int32)

Acceleration returns the last read acceleration 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 (*Device) Configure

func (d *Device) Configure(config Config) error

func (*Device) Connected

func (d *Device) Connected() bool

func (*Device) Steps

func (d *Device) Steps() (steps uint32)

Steps returns the number of steps counted since the BMA42x sensor was initialized.

func (*Device) Temperature

func (d *Device) Temperature() int32

Temperature returns the last read temperature in celsius milli degrees (1°C is 1000).

func (*Device) Update

func (d *Device) Update(which drivers.Measurement) error

type DeviceType

type DeviceType uint8
const (
	DeviceBMA421 DeviceType = 1 << iota
	DeviceBMA425

	AnyDevice = DeviceBMA421 | DeviceBMA425
)

type Features

type Features uint8

Features to enable while configuring the accelerometer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL