pyupm_h3lis331dl module

class pyupm_h3lis331dl.H3LIS331DL(bus, address=24)[source]

Bases: object

API for the H3LIS331DL-based Grove 3-Axis Digital Accelerometer (400g)

ID: h3lis331dl

Name: I2C 3-axis Digital Accelerometer (400g)

Other Names: Grove 3-Axis Digital Accelerometer (400g)

Category: accelerometer

Manufacturer: seeed stmicro

Link:http://www.seeedstudio.com/depot/Grove-3Axis-Digital- Accelerometer400g-p-1897.html

Connection: i2c This is a high-performance, high-range accelerometer for extreme applications.

C++ includes: h3lis331dl.hpp

DR_1000_780 = 3
DR_100_74 = 1
DR_400_292 = 2
DR_50_37 = 0
FS_100 = 0
FS_200 = 1
FS_400 = 3
HPCF_16 = 1
HPCF_32 = 2
HPCF_64 = 3
HPCF_8 = 0
HPM_NORMAL0 = 0
HPM_NORMAL1 = 2
HPM_REF = 1
INT_CFG_AOI = 128
INT_CFG_XHIE = 2
INT_CFG_XLIE = 1
INT_CFG_YHIE = 8
INT_CFG_YLIE = 4
INT_CFG_ZHIE = 32
INT_CFG_ZLIE = 16
INT_SRC_IA = 64
INT_SRC_XH = 2
INT_SRC_XL = 1
INT_SRC_YH = 8
INT_SRC_YL = 4
INT_SRC_ZH = 32
INT_SRC_ZL = 16
I_BOOTING = 3
I_DR = 2
I_OR = 1
I_SRC = 0
PM_LP05 = 2
PM_LP1 = 3
PM_LP10 = 6
PM_LP2 = 4
PM_LP5 = 5
PM_NORMAL = 1
PM_POWERDWN = 0
REG1_DR0 = 8
REG1_DR1 = 16
REG1_DR_SHIFT = 3
REG1_PM0 = 32
REG1_PM1 = 64
REG1_PM2 = 128
REG1_PM_SHIFT = 5
REG1_XEN = 1
REG1_YEN = 2
REG1_ZEN = 4
REG2_BOOT = 128
REG2_FDS = 16
REG2_HPCF0 = 1
REG2_HPCF1 = 2
REG2_HPCF_SHIFT = 0
REG2_HPEN1 = 4
REG2_HPEN2 = 8
REG2_HPM0 = 32
REG2_HPM1 = 64
REG2_HPM_SHIFT = 5
REG3_I1_CFG0 = 1
REG3_I1_CFG1 = 2
REG3_I1_CFG_SHIFT = 0
REG3_I2_CFG0 = 8
REG3_I2_CFG1 = 16
REG3_I2_CFG_SHIFT = 3
REG3_IHL = 128
REG3_LIR1 = 4
REG3_LIR2 = 32
REG3_PP_OD = 64
REG4_BDU = 128
REG4_BLE = 64
REG4_FS0 = 16
REG4_FS1 = 32
REG4_FS_SHIFT = 4
REG4_SIM = 1
REG5_TURNON0 = 1
REG5_TURNON1 = 2
REG_HP_FILTER_RESET = 37
REG_INT1_CFG = 48
REG_INT1_DUR = 51
REG_INT1_SRC = 49
REG_INT1_THS = 50
REG_INT2_CFG = 52
REG_INT2_DUR = 55
REG_INT2_SRC = 53
REG_INT2_THS = 54
REG_OUT_X_H = 41
REG_OUT_X_L = 40
REG_OUT_Y_H = 43
REG_OUT_Y_L = 42
REG_OUT_Z_H = 45
REG_OUT_Z_L = 44
REG_REFERENCE = 38
REG_REG1 = 32
REG_REG2 = 33
REG_REG3 = 34
REG_REG4 = 35
REG_REG5 = 36
REG_STATUS = 39
REG_WHOAMI = 15
STATUS_XDA = 1
STATUS_XOR = 16
STATUS_YDA = 2
STATUS_YOR = 32
STATUS_ZDA = 4
STATUS_ZOR = 64
STATUS_ZYXDA = 8
STATUS_ZYXOR = 128
boot()[source]

bool boot()

Boots the device. Booting the device causes internal flash calibration values to be reloaded into the visible registers in case they have been corrupted. This function returns when the booting is complete.

True if successful

enableAxis(axisEnable)[source]

bool enableAxis(uint8_t axisEnable)

Enables one or more of the 3 axes. The argument is a bitmask composed of REG1_XEN, REG1_YEN, and/or REG1_ZEN corresponding to the axes you want enabled.

axisEnable: Bitmask of axes to enable (REG1_XEN | REG1_YEN | REG1_ZEN)

True if successful

enableBDU(enable)[source]

bool enableBDU(bool enable)

Enables block data update. When enabled, low/high output registers are not updated until both low and high values have been read.

enable: True to enable, false otherwise

True if successful

enableBLE(enable)[source]

bool enableBLE(bool enable)

Enables big-endian output for 16b reads

enable: True to enable, false otherwise

True if successful

enableFDS(enable)[source]

bool enableFDS(bool enable)

Enables filtered data selection

enable: True to enable, false otherwise

True if successful

enableHPF1(enable)[source]

bool enableHPF1(bool enable)

Enables a high-pass filter for interrupt 1 source

enable: True to enable the filter, false otherwise

True if successful

enableHPF2(enable)[source]

bool enableHPF2(bool enable)

Enables a high-pass filter for interrupt 2 source

enable: True to enable the filter, false otherwise

True if successful

enableSleepToWake(enable)[source]

bool enableSleepToWake(bool enable)

Enables sleep-to-wake functionality

enable: True to enable, false otherwise

True if successful

getAcceleration(*args)[source]

std::vector< float > getAcceleration()

Gets acceleration values for each of the axes

std::vector containing X, Y, Z acceleration values

getChipID()[source]

uint8_t getChipID()

Reads and returns the chip ID (WHO_AM_I register)

True if successful

getRawXYZ(*args)[source]

std::vector< int > getRawXYZ()

Gets raw axis values

std::vector containing X, Y, Z raw values

getStatus()[source]

uint8_t getStatus()

Returns the contents of the REG_STATUS register

Contents of the REG_STATUS register

getXYZ(*args)[source]

std::vector< int > getXYZ()

Gets adjusted axis values

std::vector containing X, Y, Z adjusted axis values

i2cContext()[source]

mraa::I2c& i2cContext()

Provides public access to the MRAA I2C context of the class for direct user access

Reference to the class I2C context

init(*args)[source]

bool init(DR_BITS_T odr=DR_50_37, PM_BITS_T pm=PM_NORMAL, FS_BITS_T fs=FS_100)

Sets up initial values and starts operation

odr: Data rate: one of the DR_BITS_T values

pm: Power mode: one of the PM_BITS_T values

fs: FullScale: one of the FS_BITS_T values

True if successful

setAdjustmentOffsets(adjX, adjY, adjZ)[source]

void setAdjustmentOffsets(int adjX, int adjY, int adjZ)

Sets adjustment offsets for each of the axes. This can be used for calibration. The values supplied here are subtracted from the axis data read from the device.

adjX: Amount by which to correct the X-axis measurement

adjY: Amount by which to correct the Y-axis measurement

adjZ: Amount by which to correct the Z-axis measurement

setDataRate(odr)[source]

bool setDataRate(DR_BITS_T odr)

Sets the output data rate

odr: One of the DR_BITS_T values

True if successful

setFullScale(fs)[source]

bool setFullScale(FS_BITS_T fs)

Sets the scaling factor to 100g, 200g, or 400g

fs: One of the FS_BITS_T values

True if successful

setHPCF(val)[source]

bool setHPCF(HPCF_BITS_T val)

Sets a high-pass cutoff filter

val: One of the HPCF_BITS_T values

True if successful

setHPM(val)[source]

bool setHPM(HPM_BITS_T val)

Sets a high-pass filter mode

val: One of the HPM_BITS_T values

True if successful

setInterrupt1Config(val)[source]

bool setInterrupt1Config(uint8_t val)

Sets up the interrupt 1 config register

val: Bitmask of desired INT_CFG_BITS_T bits

True if successful

setInterrupt1Duration(val)[source]

bool setInterrupt1Duration(uint8_t val)

Sets up the interrupt 1 duration register

val: Duration to set

True if successful

setInterrupt1Latch(enable)[source]

bool setInterrupt1Latch(bool enable)

Enables interrupt 1 latch

enable: True to enable, false otherwise

True if successful

setInterrupt1PadConfig(val)[source]

bool setInterrupt1PadConfig(I_CFG_BITS_T val)

Sets the interrupt 1 pad configuration

val: One fo the I_CFG_BITS_T values

True if successful

setInterrupt1Source(val)[source]

bool setInterrupt1Source(uint8_t val)

Sets up the interrupt 1 source register

val: Bitmask of desired INT_SRC_BITS_T bits

True if successful

setInterrupt1Threshold(val)[source]

bool setInterrupt1Threshold(uint8_t val)

Sets up the interrupt 1 threshold register

val: Threshold to set

True if successful

setInterrupt2Config(val)[source]

bool setInterrupt2Config(uint8_t val)

Sets up the interrupt 2 config register

val: Bitmask of desired INT_CFG_BITS_T bits

True if successful

setInterrupt2Duration(val)[source]

bool setInterrupt2Duration(uint8_t val)

Sets up the interrupt 2 duration register

val: Duration to set

True if successful

setInterrupt2Latch(enable)[source]

bool setInterrupt2Latch(bool enable)

Enables interrupt 2 latch

enable: True to enable, false otherwise

True if successful

setInterrupt2PadConfig(val)[source]

bool setInterrupt2PadConfig(I_CFG_BITS_T val)

Sets the interrupt 2 pad configuration

val: One fo the I_CFG_BITS_T values

True if successful

setInterrupt2Source(val)[source]

bool setInterrupt2Source(uint8_t val)

Sets up the interrupt 2 source register

val: Bitmask of desired INT_SRC_BITS_T bits

True if successful

setInterrupt2Threshold(val)[source]

bool setInterrupt2Threshold(uint8_t val)

Sets up the interrupt 2 threshold register

val: Threshold to set

True if successful

setInterruptActiveLow(enable)[source]

bool setInterruptActiveLow(bool enable)

Sets interrupts to be active low instead of high

enable: True to enable, false otherwise

True if successful

setInterruptOpenDrain(enable)[source]

bool setInterruptOpenDrain(bool enable)

Sets an interrupt output mode to open drain rather than push/pull

enable: True to enable, false otherwise

True if successful

setPowerMode(pm)[source]

bool setPowerMode(PM_BITS_T pm)

Sets the power mode

pm: One of the PM_BITS_T values

True if successful

update()[source]

void update()

Reads the sensor and stores current values internally