pyupm_lsm303agr module

class pyupm_lsm303agr.LSM303AGR(bus=0, acc_addr=25, mag_addr=30)[source]

Bases: object

API for the LSM303AGR 3-Axis Geomagnetic Sensor.

ID: lsm303agr

Name: Ultra-compact high-performance eCompass module

Category: compass

Manufacturer: stmicro

Connection: i2c gpio

Link:http://www.st.com/en/mems-and-sensors/lsm303agr.html The LSM303AGR is an ultra-low-power high-performance system-in-package featuring a 3D digital linear acceleration sensor and a 3D digital magnetic sensor. The LSM303AGR 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: lsm303agr.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

getAccelerometerInt1Config()[source]

uint8_t getAccelerometerInt1Config()

Return the accelerometer interrupt 1 config register. This register allows you to enable various interrupt conditions. See the datasheet for details.

A bitmask of LSM303AGR_INT_CFG_A_BITS_T bits

getAccelerometerInt1Src()[source]

uint8_t getAccelerometerInt1Src()

Return the accelerometer interrupt 1 source register. This register indicates which interrupts have been triggered. See the datasheet for details.

a bitmask of LSM303AGR_INT_SRC_A_BITS_T bits

getAccelerometerInt2Config()[source]

uint8_t getAccelerometerInt2Config()

Return the accelerometer interrupt 2 config register. This register allows you to enable various interrupt conditions. See the datasheet for details.

A bitmask of LSM303AGR_INT_CFG_A_BITS_T bits

getAccelerometerInt2Src()[source]

uint8_t getAccelerometerInt2Src()

Return the accelerometer interrupt 2 source register. This register indicates which interrupts have been triggered. See the datasheet for details.

a bitmask of LSM303AGR_INT_SRC_A_BITS_T bits

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

getMagnetometerIntConfig()[source]

uint8_t getMagnetometerIntConfig()

Return the magnetometer interrupt config register. See the datasheet for details.

A bitmask of LSM303AGR_INT_CTRL_REG_M_BITS_T bits

getMagnetometerIntSrc()[source]

uint8_t getMagnetometerIntSrc()

Return the magnetometer (mag) interrupt source register. This register indicates which interrupts have been triggered. See the datasheet for details.

dev: The device context

a bitmask of LSM303AGR_INT_SRC_REG_M_BITS_T bits

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(usage=2)[source]

void init(LSM303AGR_POWER_MODE_T usage=LSM303AGR_POWER_HIGH_RESOLUTION)

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.

For the accelerometer, the full scale will be set to 2G, mode continuous, all axes enabled, BDU enabled, temperature measurement enabled, and an output data rate (ODR) of 100Hz with the power mode set at high resolution.

For the magnetometer, temperature compensation will be enabled, mode continuous, and an output data rate of 10Hz with the power mode set at high resolution.

usage: One of the LSM303AGR_POWER_MODE_T values. The default is LSM303AGR_POWER_HIGH_RESOLUTION.

std::runtime_error: on failure

installISR(intr, gpio, level, isr, arg)[source]

void installISR(LSM303AGR_INTERRUPT_PINS_T intr, int gpio, mraa::Edge level, void(*isr)(void *), void *arg)

Install an interrupt handler

intr: One of the LSM303AGR_INTERRUPT_PINS_T values specifying which interrupt pin you are installing

gpio: GPIO pin to use as interrupt pin

level: The interrupt trigger level (one of mraa::Edge values). Make sure that you have configured the interrupt pin properly for whatever level you choose.

isr: The interrupt handler, accepting a void * argument

arg: The argument to pass the the interrupt handler

std::runtime_error: on failure

setAccelerometerInt1Config(bits)[source]

void setAccelerometerInt1Config(uint8_t bits)

Set the accelerometer interrupt 1 config register. See the datasheet for details.

dev: The device context

bits: A bitmask of LSM303AGR_INT_CFG_A_BITS_T bits

std::runtime_error: on failure

setAccelerometerInt2Config(bits)[source]

void setAccelerometerInt2Config(uint8_t bits)

Set the accelerometer interrupt 2 config register. See the datasheet for details.

dev: The device context

bits: A bitmask of LSM303AGR_INT_CFG_A_BITS_T bits

std::runtime_error: on failure

setAccelerometerODR(odr)[source]

void setAccelerometerODR(LSM303AGR_A_ODR_T odr)

Set the accelerometer output data rate (ODR)

odr: One of the LSM303AGR_A_ODR_T values. The default set at initialization time is LSM303AGR_A_ODR_100HZ.

std::runtime_error: on failure

setFullScale(fs)[source]

void setFullScale(LSM303AGR_A_FS_T fs)

Set the full scale (sensitivity) value for the accelerometer. This device supports 2G, 4G, 8G, and 16G full scale modes.

fs: One of the LSM303AGR_A_FS_T values

std::runtime_error: on failure

setMagnetometerIntConfig(bits)[source]

void setMagnetometerIntConfig(uint8_t bits)

Set the magnetometer (mag) interrupt config register. See the datasheet for details.

bits: A bitmask of LSM303AGR_INT_CTRL_REG_M_BITS_T bits

std::runtime_error: on failure

setMagnetometerODR(odr)[source]

void setMagnetometerODR(LSM303AGR_CFG_A_M_ODR_T odr)

Set the magnetometer output data rate (ODR)

odr: One of the LSM303AGR_CFG_A_M_ODR_T values. The default set at initialization time is LSM303AGR_CFG_A_M_ODR_10HZ.

std::runtime_error: on failure

setPowerMode(mode)[source]

void setPowerMode(LSM303AGR_POWER_MODE_T mode)

Set an operating power mode. There are 3 modes available: low power, normal, and high resolution.

mode: One of the LSM303AGR_POWER_MODE_T values. The default set at initialization time is LSM303AGR_POWER_HIGH_RESOLUTION.

std::runtime_error: on failure

uninstallISR(intr)[source]

void uninstallISR(LSM303AGR_INTERRUPT_PINS_T intr)

Uninstall a previously installed interrupt handler

intr: One of the LSM303AGR_INTERRUPT_PINS_T values specifying which interrupt pin you are removing

update()[source]

void update()

Update the internal stored values from sensor data. This method must be called before querying the acceleration, magnetometer, or temperature.

std::runtime_error: on failure

class pyupm_lsm303agr.SwigPyIterator(*args, **kwargs)[source]

Bases: object

advance(n)[source]
copy()[source]
decr(n=1)[source]
distance(x)[source]
equal(x)[source]
incr(n=1)[source]
next()[source]
previous()[source]
value()[source]
class pyupm_lsm303agr.byteVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_lsm303agr.doubleVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_lsm303agr.floatVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_lsm303agr.int16Vector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_lsm303agr.intVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]