PropWare
C++ objects and CMake build system for Parallax Propeller
|
#include <lsm303dlhc.h>
Public Member Functions | |
LSM303DLHC () | |
bool | Init (libpropeller::I2C *i2c_bus) |
bool | ReadAccl (int &x, int &y, int &z) |
bool | ReadMagn (int &x, int &y, int &z) |
Provides an interface to the LSM303DLHC accelerometer and magnetometer.
"Output Data Rate, in digital-output accelerometers, defines the rate at which data is sampled. Bandwidth is the highest frequency signal that can be sampled without aliasing by the specified Output Data Rate. Per the Nyquist sampling criterion, bandwidth is half the Output Data Rate." -Analog Devices
See this question for more information on ODR: http://electronics.stackexchange.com/questions/67610/lsm303dlhc-low-power-and-high-precision-modes
Definition at line 21 of file lsm303dlhc.h.
libpropeller::LSM303DLHC::LSM303DLHC | ( | ) |
Create a new LSM303DLHC instance.
Definition at line 26 of file lsm303dlhc.h.
bool libpropeller::LSM303DLHC::Init | ( | libpropeller::I2C * | i2c_bus | ) |
Tests to make sure that the LSM303DLHC is actually on the bus, and returns false if it is not. Otherwise, sets the registers as follows and returns true.
Set the control registers of the accelerometer:
Set the control registers of the Magn :
Continuous conversion mode (SRLM: What does this actually mean? Datasheet is no help)
i2cbus | The bus that the LSM303DLHC is on. |
Definition at line 65 of file lsm303dlhc.h.
bool libpropeller::LSM303DLHC::ReadAccl | ( | int & | x, |
int & | y, | ||
int & | z | ||
) |
Reads the accelerometer at the current settings, and updates the three reference values.
If there is an error then x, y, and z will be set to zero and false will be returned.
x | The acceleration x axis value. Will be overwritten. |
y | The acceleration y axis value. Will be overwritten. |
z | The acceleration z axis value. Will be overwritten. |
Definition at line 101 of file lsm303dlhc.h.
bool libpropeller::LSM303DLHC::ReadMagn | ( | int & | x, |
int & | y, | ||
int & | z | ||
) |
Reads the magnetometer at the current settings, and updates the three reference values.
If there is an error then x, y, and z will be set to zero and false will be returned.
x | The magnetometer x axis value. Will be overwritten. |
y | The magnetometer y axis value. Will be overwritten. |
z | The magnetometer z axis value. Will be overwritten. |
Definition at line 134 of file lsm303dlhc.h.