Documentation ¶
Overview ¶
Package adxl345 implements the MovementSensor interface for the ADXL345 accelerometer.
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 ¶
func NewAdxl345 ¶
func NewAdxl345( ctx context.Context, deps resource.Dependencies, conf resource.Config, logger golog.Logger, ) (movementsensor.MovementSensor, error)
NewAdxl345 is a constructor to create a new object representing an ADXL345 accelerometer.
Types ¶
type Config ¶ added in v0.2.36
type Config struct { BoardName string `json:"board"` I2cBus string `json:"i2c_bus"` UseAlternateI2CAddress bool `json:"use_alternate_i2c_address,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.
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
ValidateTapConfigs validates the tap piece of the config.
Click to show internal directories.
Click to hide internal directories.