[−][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 (providing normalized readings) and/or
the RawAccelerometer trait (providing direct access to raw data) for
your driver (ideally the former, as it provides reuse across drivers).
For RawAccelerometer, you will need to choose a Vector type for
raw accelerometer data which best matches the output of your device.
This trait has a single method, RawAccelerometer::accel_raw, which
returns a reading from the accelerometer or an error.
See the ADXL343 crate for an example.
Re-exports
pub use crate::error::*; |
pub use crate::orientation::*; |
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. |
Traits
| Accelerometer | Accelerometer trait which provides g-normalized readings. |
| RawAccelerometer | Read raw acceleration vectors of type |
| Vector | Vectors with numeric components |