pyupm_lsm303d module¶
-
class
pyupm_lsm303d.
LSM303D
(bus=0, addr=30)[source]¶ Bases:
object
API for the LSM303D 3-Axis Geomagnetic Sensor.
ID: lsm303d
Name: Ultra-compact high-performance eCompass module
Category: compass
Manufacturer: stmicro
Connection: i2c gpio
Link:http://www.st.com/en/mems-and-sensors/lsm303d.html The LSM303D is an ultra-low-power high-performance system-in-package featuring a 3D digital linear acceleration sensor and a 3D digital magnetic sensor. The LSM303D has linear acceleration full scales of 2g/4g/8g/16g and a magnetic field dynamic range of 50 Gauss.
Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports only I2C operation.
This device requires 3.3v operation.
C++ includes: lsm303d.hpp
-
getAccelerometer
(*args)[source]¶ std::vector< float > getAccelerometer()
Return acceleration data in gravities in the form of a floating point vector. update() must have been called prior to calling this method.
A floating point vector containing x, y, and z in that order
-
getMagnetometer
(*args)[source]¶ std::vector< float > getMagnetometer()
Return magnetometer data in micro-Teslas (uT) in the form of a floating point vector. update() must have been called prior to calling this method.
A floating point vector containing x, y, and z in that order
-
getTemperature
()[source]¶ float getTemperature()
Return temperature data in degrees Celsius. NOTE: This is not the ambient room temperature. update() must have been called prior to calling this method.
Temperature in degrees Celsius
-
init
(res)[source]¶ void init(LSM303D_M_RES_T res)
Initialize the device and start operation. This function is called from the constructor so it will not typically need to be called by a user unless the device is reset. It will initialize the accelerometer and magnetometer (if enabled) to certain default running modes.
res: One of the LSM303D_M_RES_T values. This value sets the resolution of the magnetometer. At init time, this value is set to LSM303D_M_RES_HIGH.
std::runtime_error: on failure
-
setAccelerometerFullScale
(fs)[source]¶ void setAccelerometerFullScale(LSM303D_AFS_T fs)
Set the full scale (sensitivity) value for the accelerometer. This device supports 2G, 4G, 6G, 8G, and 16G full scale modes.
fs: One of the LSM303D_AFS_T values
std::runtime_error: on failure
-
setAccelerometerODR
(odr)[source]¶ void setAccelerometerODR(LSM303D_AODR_T odr)
Set the accelerometer output data rate (ODR)
odr: One of the LSM303D_AODR_T values. The default set at initialization time is LSM303D_AODR_100HZ.
std::runtime_error: on failure
-
setMagnetometerFullScale
(fs)[source]¶ void setMagnetometerFullScale(LSM303D_MFS_T fs)
Set the full scale (sensitivity) value for the magnetometer. This device supports 2, 4, 8, and 16 Gauss full scale modes.
fs: One of the LSM303D_MFS_T values
std::runtime_error: on failure
-