[][src]Crate accelerometer

Generic embedded-friendly accelerometer support, including traits and types for representing readings from 2 or 3-axis accelerometers.

Also includes optional device position tracking support with statistical methods for smoothing out noisy accelerometer data.

Writing an accelerometer driver

The accelerometer crate is intended to provide a "HAL" for accelerometers which allows several accelerometer-consuming crates to leverage a common API and set of vector types for consuming accelerometer data.

Accelerometer drivers are intended to use embedded-hal I2C or SPI interfaces. The first task of writing a driver is to choose one of these and write a driver which is able to communicate with the accelerometer and obtain data.

Next, impl the Accelerometer trait for your driver. You will need to choose a Vector type for representing accelerometer data which best matches the output of your device. This trait has a single method, Accelerometer::acceleration, which returns a reading from the accelerometer or an error.

See the ADXL343 crate for an example.

Re-exports

pub use crate::orientation::*;
pub use crate::error::*;

Modules

error

Accelerometer errors - generic over an inner "cause" type (intended to be an underlying I2C or SPI error type, if applicable)

orientation

Orientation tracking for accelerometer-equipped devices

vector

Algebraic vector types generic over a number of axes and a component type.

Structs

F32x2

2-dimensional XY vector of f32 values

F32x3

3-dimensional XYZ vector of f32 values

I16x2

2-dimensional XY vector of i16 values

I16x3

3-dimensional XYZ vector of i16 values

I32x2

2-dimensional XY vector of i32 values

I32x3

3-dimensional XYZ vector of i32 values

I8x2

2-dimensional XY vector of i8 values

I8x3

3-dimensional XYZ vector of i8 values

Iter

Iterator over the components of an algebraic vector

U16x2

2-dimensional XY vector of u16 values

U16x3

3-dimensional XYZ vector of u16 values

U32x2

2-dimensional XY vector of u32 values

U32x3

3-dimensional XYZ vector of u16 values

U8x2

2-dimensional XY vector of u8 values

U8x3

3-dimensional XYZ vector of u8 values

Traits

Accelerometer

Accelerometers which measure acceleration vectors of type V

Component

Vector components. All components must be Copy + Sized types which support basic arithmetic (Add, Sub, Mul, Div), as well as Default, PartialEq and PartialOrd.

Vector

Vectors with numeric components

VectorExt

Vector geometry extensions usable on vectors whose components can be converted into f32.