adxl345

package
v0.21.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package adxl345 implements the MovementSensor interface for the ADXL345 accelerometer.

Package adxl345 is Linux-only.

Package adxl345 is for an ADXL345 accelerometer. This file is for the interrupt-based functionality on the chip.

Index

Constants

View Source
const (
	// an unsigned time value representing the maximum time that an event must be above the
	// THRESH_TAP threshold to qualify as a tap event [625 µs/LSB].
	DurAddr byte = 0x21
	// info on which interrupts have been enabled.
	IntEnableAddr byte = 0x2E
	// info on which interrupt pin to send each interrupt.
	IntMapAddr byte = 0x2F
	// info on which interrupt has gone off since the last time this address has been read from.
	IntSourceAddr byte = 0x30
	// an unsigned time value representing the wait time from the detection of a tap event to the
	// start of the time window [1.25 ms/LSB].
	LatentAddr byte = 0x22
	// info on which axes have been turned on for taps (X, Y, Z are bits 2, 1, 0 respectively).
	TapAxesAddr byte = 0x2A
	// an unsigned threshold value for tap interrupts [62.5 mg/LSB ].
	ThreshTapAddr byte = 0x1D
	// che threshold value, in unsigned format, for free-fall detection.
	ThreshFfAddr byte = 0x28
	// the  minimum time that the value of all axes must be less than THRESH_FF to generate a free-fall interrupt.
	TimeFfAddr byte = 0x29
)

addresses relevant to interrupts.

View Source
const (
	// ThreshTapScaleFactor is the scale factor for THRESH_TAP register.
	ThreshTapScaleFactor float32 = 62.5
	// DurScaleFactor is the scale factor for DUR register.
	DurScaleFactor float32 = 625
	// TimeFfScaleFactor is the scale factor for TIME_FF register.
	TimeFfScaleFactor float32 = .5
	// ThreshFfScaleFactor is the scale factor for THRESH_FF register.
	ThreshFfScaleFactor float32 = 62.5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.2.36

type Config struct {
	I2cBus                 string          `json:"i2c_bus"`
	UseAlternateI2CAddress bool            `json:"use_alternate_i2c_address,omitempty"`
	BoardName              string          `json:"board,omitempty"`
	SingleTap              *TapConfig      `json:"tap,omitempty"`
	FreeFall               *FreeFallConfig `json:"free_fall,omitempty"`
}

Config is a description of how to find an ADXL345 accelerometer on the robot.

func (*Config) Validate added in v0.2.36

func (cfg *Config) Validate(path string) ([]string, error)

Validate ensures all parts of the config are valid, and then returns the list of things we depend on.

type FreeFallConfig added in v0.2.36

type FreeFallConfig struct {
	AccelerometerPin int     `json:"accelerometer_pin"`
	InterruptPin     string  `json:"interrupt_pin"`
	Threshold        float32 `json:"threshold,omitempty"`
	Time             float32 `json:"time_ms,omitempty"`
}

FreeFallConfig is a description of the configs for free fall registers.

func (*FreeFallConfig) ValidateFreeFallConfigs added in v0.2.36

func (freefallCfg *FreeFallConfig) ValidateFreeFallConfigs(path string) error

ValidateFreeFallConfigs validates the freefall piece of the config.

type InterruptID added in v0.2.26

type InterruptID = uint8

InterruptID is a type of interrupts available on ADXL345.

const (
	// SingleTap is a key value used to find various needs associated with this interrupt.
	SingleTap InterruptID = iota
	// FreeFall is a key value used to find various needs associated with this interrupt.
	FreeFall InterruptID = iota
)

type TapConfig added in v0.2.36

type TapConfig struct {
	AccelerometerPin int     `json:"accelerometer_pin"`
	InterruptPin     string  `json:"interrupt_pin"`
	ExcludeX         bool    `json:"exclude_x,omitempty"`
	ExcludeY         bool    `json:"exclude_y,omitempty"`
	ExcludeZ         bool    `json:"exclude_z,omitempty"`
	Threshold        float32 `json:"threshold,omitempty"`
	Dur              float32 `json:"dur_us,omitempty"`
}

TapConfig is a description of the configs for tap registers.

func (*TapConfig) ValidateTapConfigs added in v0.2.36

func (tapCfg *TapConfig) ValidateTapConfigs(path string) error

ValidateTapConfigs validates the tap piece of the config.

Jump to

Keyboard shortcuts

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