Struct lsm303agr::Lsm303agr [−][src]
pub struct Lsm303agr<DI, MODE> { /* fields omitted */ }
Expand description
LSM303AGR device driver
Implementations
Set accelerometer output data rate.
This changes the power mode if the current one is not appropriate. When changing from a low-power-only output data rate setting into a high-resolution or normal power mode, it changes into normal mode.
Set accelerometer power/resolution mode
Returns Error::InvalidInputData
if the mode is incompatible with the current
accelerometer output data rate.
Get the accelerometer mode
Set accelerometer scaling factor
This changes the scale at which the acceleration is read.
AccelScale::G2
for example can return values between -2g and +2g
where g is the gravity of the earth (~9.82 m/s²).
Get accelerometer scaling factor
Create new instance of the LSM303AGR device communicating through I2C.
Create new instance of the LSM303AGR device communicating through SPI.
Accelerometer status
Accelerometer data
Returned in mg (milli-g) where 1g is 9.8m/s².
If you need the raw unscaled measurement see Lsm303agr::accel_data_unscaled
.
Unscaled accelerometer data
Magnetometer status
Get accelerometer device ID
Read and verify the accelerometer device ID
Get magnetometer device ID
Read and verify the magnetometer device ID
pub fn into_mag_continuous(
self
) -> Result<Lsm303agr<DI, MagContinuous>, ModeChangeError<CommE, PinE, Self>>
pub fn into_mag_continuous(
self
) -> Result<Lsm303agr<DI, MagContinuous>, ModeChangeError<CommE, PinE, Self>>
Change the magnetometer to continuous measurement mode
pub fn into_mag_one_shot(
self
) -> Result<Lsm303agr<DI, MagOneShot>, ModeChangeError<CommE, PinE, Self>>
pub fn into_mag_one_shot(
self
) -> Result<Lsm303agr<DI, MagOneShot>, ModeChangeError<CommE, PinE, Self>>
Change the magnetometer to one-shot mode
After this the magnetometer is in idle mode until a one-shot measurement is started.
Set magnetometer output data rate
Magnetometer data
Returned in nT (nanotesla)
If you need the raw unscaled measurement see Lsm303agr::mag_data_unscaled
.
Unscaled magnetometer data
Magnetometer data in nT (nanoteslas)
Unscaled magnetometer data