pyupm_lsm6dsl module

class pyupm_lsm6dsl.LSM6DSL(bus=0, addr=106, cs=-1)[source]

Bases: object

API for the LSM6DSL 3-axis Accelerometer and Gyroscope.

ID: lsm6dsl

Name: Digital 3-axis Accelerometer and Gyroscope

Category: accelerometer gyro

Manufacturer: stmicro

Connection: i2c spi gpio

Link:http://www.st.com/en/mems-and-sensors/lsm6dsl.html The LSM6DSL is a system-in-package featuring a 3D digital accelerometer and a 3D digital gyroscope performing at 0.65 mA in high performance mode and enabling always-on low-power features for an optimal motion experience for the consumer.

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 both I2C (default) and SPI operation.

C++ includes: lsm6dsl.hpp

getAccelerometer(*args)[source]

std::vector< float > getAccelerometer()

Return accelerometer 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

getChipID()[source]

uint8_t getChipID()

Return the chip ID

The chip ID

getGyroscope(*args)[source]

std::vector< float > getGyroscope()

Return gyroscope data in degrees per second 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

getStatus()[source]

uint8_t getStatus()

Return the contents of the status register

A bitmask of values from LSM6DSL_STATUS_BITS_T

getTemperature(fahrenheit=False)[source]

float getTemperature(bool fahrenheit=false)

Return the current measured temperature. Note, this is not ambient temperature. update() must have been called prior to calling this method.

fahrenheit: true to return data in Fahrenheit, false for Celicus. Celsius is the default.

The temperature in degrees Celsius or Fahrenheit

init(acc_odr=4, acc_fs=0, gyr_odr=4, gyr_fs=0)[source]

void init(LSM6DSL_XL_ODR_T acc_odr=LSM6DSL_XL_ODR_104HZ, LSM6DSL_XL_FS_T acc_fs=LSM6DSL_XL_FS_2G, LSM6DSL_G_ODR_T gyr_odr=LSM6DSL_G_ODR_104HZ, LSM6DSL_G_FS_T gyr_fs=LSM6DSL_G_FS_245DPS)

Initialize the device and start operation. This function is called from the constructor, so it will not need to be called by a user unless the device is reset. It sets the accelerometer and gyroscope ODR and FS modes, and enables BDU, register auto-increment, and high performance mode.

acc_odr: One of the LSM6DSL_XL_ODR_T values

acc_fs: One of the LSM6DSL_XL_FS_T values

gyr_odr: One of the LSM6DSL_G_ODR_T values

gyr_fs: One of the LSM6DSL_G_FS_T values

std::runtime_error: on failure

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

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

install an interrupt handler

intr: One of the LSM6DSL_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

readReg(reg)[source]

uint8_t readReg(uint8_t reg)

Read a register

reg: The register to read

The value of the register

readRegs(reg, buffer, len)[source]

int readRegs(uint8_t reg, uint8_t *buffer, int len)

Read contiguous registers into a buffer

buffer: The buffer to store the results

len: The number of registers to read

The number of bytes read

std::runtime_error: on failure

reset()[source]

void reset()

Reset the device as if during a power on reset. All configured values are lost when this happens. You should call init() afterwards, or at least perform the same initialization init() does before continuing.

std::runtime_error: on failure

setAccelerometerFullScale(fs)[source]

void setAccelerometerFullScale(LSM6DSL_XL_FS_T fs)

Set the full scale (FS) of the accelerometer. This device supports a full scale of 2, 4, 8, and 16G.

fs: One of the LSM6DSL_XL_FS_T values

std::runtime_error: on failure

setAccelerometerODR(odr)[source]

void setAccelerometerODR(LSM6DSL_XL_ODR_T odr)

Set the output data rate (ODR) of the accelerometer

odr: One of the LSM6DSL_XL_ODR_T values

std::runtime_error: on failure

setAccelerometerOffsets(x, y, z, weight)[source]

void setAccelerometerOffsets(int x, int y, int z, bool weight)

Set accelerometer offsets for each axis. In the case of X and Y, the offsets will be internally added before being placed into the output registers. For the Z offset, the value will be subtracted before being placed into the output registers. The weight is used to determine the weighing of the offset bits. All offsets must be in the range of -127 to 127.

x: X axis offset in the range -127 to 127

y: Y axis offset in the range -127 to 127

z: Z axis offset in the range -127 to 127

weight: When true, the the offset will be weighted at 2^-6 g/LSB, when false the weighting will be 2^-10 g/LSB

std::runtime_error: on failure

setGyroscopeFullScale(fs)[source]

void setGyroscopeFullScale(LSM6DSL_G_FS_T fs)

Set the full scale (FS) of the gyroscope

fs: One of the LSM6DSL_G_FS_T values

std::runtime_error: on failure

setGyroscopeODR(odr)[source]

void setGyroscopeODR(LSM6DSL_G_ODR_T odr)

Set the output data rate (ODR) of the gyroscope

odr: One of the LSM6DSL_G_ODR_T values

std::runtime_error: on failure

setHighPerformance(enable)[source]

void setHighPerformance(bool enable)

Enable accelerometer and gyroscope high performance modes. These are further defined by the respective ODR settings to allow low power, and normal/high-performance modes. This is enabled by default in init().

enable: true to enable high performance mode, false otherwise

std::runtime_error: on failure

setInterruptActiveHigh(high)[source]

void setInterruptActiveHigh(bool high)

Indicate whether the interrupt should be active high (default) or active low. See the datasheet for details.

high: true for active high, false for active low

std::runtime_error: on failure

setInterruptPushPull(pp)[source]

void setInterruptPushPull(bool pp)

Indicate whether interrupts are push-pull (default) or open drain. See the datasheet for details.

pp: true for push-pull, false for open-drain

std::runtime_error: on failure

uninstallISR(intr)[source]

void uninstallISR(LSM6DSL_INTERRUPT_PINS_T intr)

uninstall a previously installed interrupt handler

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

update()[source]

void update()

Update the internal stored values from sensor data

std::runtime_error: on failure

writeReg(reg, val)[source]

void writeReg(uint8_t reg, uint8_t val)

Write to a register

reg: The register to write to

val: The value to write

std::runtime_error: on failure

class pyupm_lsm6dsl.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_lsm6dsl.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_lsm6dsl.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_lsm6dsl.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_lsm6dsl.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_lsm6dsl.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]