UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

H3LIS331DL Class

Module: h3lis331dl

This is a high-performance, high-range accelerometer for extreme applications.
h3lis331dl.jpg

Item Index

Methods

H3LIS331DL

(
  • bus
  • address
)
Number

H3LIS331DL constructor

Parameters:

  • bus Number

    I2C bus to use

  • address Number

    Address for this device

Returns:

Number:

init

(
  • odr
  • pm
  • fs
)
Boolean

Sets up initial values and starts operation

Parameters:

  • odr DR_BITS_T

    Data rate: one of the DR_BITS_T values

  • pm PM_BITS_T

    Power mode: one of the PM_BITS_T values

  • fs FS_BITS_T

    FullScale: one of the FS_BITS_T values

Returns:

Boolean:

True if successful

getChipID

() Number

Reads and returns the chip ID (WHO_AM_I register)

Returns:

Number:

True if successful

setDataRate

(
  • odr
)
Boolean

Sets the output data rate

Parameters:

  • odr DR_BITS_T

    One of the DR_BITS_T values

Returns:

Boolean:

True if successful

setPowerMode

(
  • pm
)
Boolean

Sets the power mode

Parameters:

  • pm PM_BITS_T

    One of the PM_BITS_T values

Returns:

Boolean:

True if successful

enableAxis

(
  • axisEnable
)
Boolean

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.

Parameters:

  • axisEnable Number

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

Returns:

Boolean:

True if successful

setFullScale

(
  • fs
)
Boolean

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

Parameters:

  • fs FS_BITS_T

    One of the FS_BITS_T values

Returns:

Boolean:

True if successful

setHPCF

(
  • val
)
Boolean

Sets a high-pass cutoff filter

Parameters:

  • val HPCF_BITS_T

    One of the HPCF_BITS_T values

Returns:

Boolean:

True if successful

setHPM

(
  • val
)
Boolean

Sets a high-pass filter mode

Parameters:

  • val HPM_BITS_T

    One of the HPM_BITS_T values

Returns:

Boolean:

True if successful

boot

() Boolean

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.

Returns:

Boolean:

True if successful

enableHPF1

(
  • enable
)
Boolean

Enables a high-pass filter for interrupt 1 source

Parameters:

  • enable Boolean

    True to enable the filter, false otherwise

Returns:

Boolean:

True if successful

enableHPF2

(
  • enable
)
Boolean

Enables a high-pass filter for interrupt 2 source

Parameters:

  • enable Boolean

    True to enable the filter, false otherwise

Returns:

Boolean:

True if successful

enableFDS

(
  • enable
)
Boolean

Enables filtered data selection

Parameters:

  • enable Boolean

    True to enable, false otherwise

Returns:

Boolean:

True if successful

setInterruptActiveLow

(
  • enable
)
Boolean

Sets interrupts to be active low instead of high

Parameters:

  • enable Boolean

    True to enable, false otherwise

Returns:

Boolean:

True if successful

setInterruptOpenDrain

(
  • enable
)
Boolean

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

Parameters:

  • enable Boolean

    True to enable, false otherwise

Returns:

Boolean:

True if successful

setInterrupt1Latch

(
  • enable
)
Boolean

Enables interrupt 1 latch

Parameters:

  • enable Boolean

    True to enable, false otherwise

Returns:

Boolean:

True if successful

setInterrupt2Latch

(
  • enable
)
Boolean

Enables interrupt 2 latch

Parameters:

  • enable Boolean

    True to enable, false otherwise

Returns:

Boolean:

True if successful

setInterrupt1PadConfig

(
  • val
)
Boolean

Sets the interrupt 1 pad configuration

Parameters:

  • val I_CFG_BITS_T

    One fo the I_CFG_BITS_T values

Returns:

Boolean:

True if successful

setInterrupt2PadConfig

(
  • val
)
Boolean

Sets the interrupt 2 pad configuration

Parameters:

  • val I_CFG_BITS_T

    One fo the I_CFG_BITS_T values

Returns:

Boolean:

True if successful

enableBDU

(
  • enable
)
Boolean

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

Parameters:

  • enable Boolean

    True to enable, false otherwise

Returns:

Boolean:

True if successful

enableBLE

(
  • enable
)
Boolean

Enables big-endian output for 16b reads

Parameters:

  • enable Boolean

    True to enable, false otherwise

Returns:

Boolean:

True if successful

enableSleepToWake

(
  • enable
)
Boolean

Enables sleep-to-wake functionality

Parameters:

  • enable Boolean

    True to enable, false otherwise

Returns:

Boolean:

True if successful

getStatus

() Number

Returns the contents of the REG_STATUS register

Returns:

Number:

Contents of the REG_STATUS register

setInterrupt1Config

(
  • val
)
Boolean

Sets up the interrupt 1 config register

Parameters:

  • val Number

    Bitmask of desired INT_CFG_BITS_T bits

Returns:

Boolean:

True if successful

setInterrupt2Config

(
  • val
)
Boolean

Sets up the interrupt 2 config register

Parameters:

  • val Number

    Bitmask of desired INT_CFG_BITS_T bits

Returns:

Boolean:

True if successful

setInterrupt1Source

(
  • val
)
Boolean

Sets up the interrupt 1 source register

Parameters:

  • val Number

    Bitmask of desired INT_SRC_BITS_T bits

Returns:

Boolean:

True if successful

setInterrupt2Source

(
  • val
)
Boolean

Sets up the interrupt 2 source register

Parameters:

  • val Number

    Bitmask of desired INT_SRC_BITS_T bits

Returns:

Boolean:

True if successful

setInterrupt1Threshold

(
  • val
)
Boolean

Sets up the interrupt 1 threshold register

Parameters:

  • val Number

    Threshold to set

Returns:

Boolean:

True if successful

setInterrupt2Threshold

(
  • val
)
Boolean

Sets up the interrupt 2 threshold register

Parameters:

  • val Number

    Threshold to set

Returns:

Boolean:

True if successful

setInterrupt1Duration

(
  • val
)
Boolean

Sets up the interrupt 1 duration register

Parameters:

  • val Number

    Duration to set

Returns:

Boolean:

True if successful

setInterrupt2Duration

(
  • val
)
Boolean

Sets up the interrupt 2 duration register

Parameters:

  • val Number

    Duration to set

Returns:

Boolean:

True if successful

update

()

Reads the sensor and stores current values internally

setAdjustmentOffsets

(
  • adjX
  • adjY
  • 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.

Parameters:

  • adjX Number

    Amount by which to correct the X-axis measurement

  • adjY Number

    Amount by which to correct the Y-axis measurement

  • adjZ Number

    Amount by which to correct the Z-axis measurement

getAcceleration

(
  • aX
  • aY
  • aZ
)

Gets acceleration values for each of the axes

Parameters:

  • aX Float *

    Returned X-axis acceleration

  • aY Float *

    Returned Y-axis acceleration

  • aZ Float *

    Returned Z-axis acceleration

getRawXYZ

(
  • x
  • y
  • z
)

Gets raw axis values

Parameters:

  • x Int *

    Returned raw X-axis value

  • y Int *

    Returned raw Y-axis value

  • z Int *

    Returned raw Z-axis value

getXYZ

(
  • x
  • y
  • z
)

Gets adjusted axis values

Parameters:

  • x Int *

    Returned X-axis value

  • y Int *

    Returned Y-axis value

  • z Int *

    Returned Z-axis value

getAcceleration

() Std::vector float

Gets acceleration values for each of the axes

Returns:

Std::vector float :

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

getRawXYZ

() Std::vector int

Gets raw axis values

Returns:

Std::vector int :

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

getXYZ

() Std::vector int

Gets adjusted axis values

Returns:

Std::vector int :

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

i2cContext

() Mraa::I2c *

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

Returns:

Mraa::I2c *:

Reference to the class I2C context

Properties

REG_WHOAMI

Enum H3LIS331DL_REG_T

REG_REG1

Enum H3LIS331DL_REG_T

REG_REG2

Enum H3LIS331DL_REG_T

REG_REG3

Enum H3LIS331DL_REG_T

REG_REG4

Enum H3LIS331DL_REG_T

REG_REG5

Enum H3LIS331DL_REG_T

REG_HP_FILTER_RESET

Enum H3LIS331DL_REG_T

REG_REFERENCE

Enum H3LIS331DL_REG_T

REG_STATUS

Enum H3LIS331DL_REG_T

REG_OUT_X_L

Enum H3LIS331DL_REG_T

REG_OUT_X_H

Enum H3LIS331DL_REG_T

REG_OUT_Y_L

Enum H3LIS331DL_REG_T

REG_OUT_Y_H

Enum H3LIS331DL_REG_T

REG_OUT_Z_L

Enum H3LIS331DL_REG_T

REG_OUT_Z_H

Enum H3LIS331DL_REG_T

REG_INT1_CFG

Enum H3LIS331DL_REG_T

REG_INT1_SRC

Enum H3LIS331DL_REG_T

REG_INT1_THS

Enum H3LIS331DL_REG_T

REG_INT1_DUR

Enum H3LIS331DL_REG_T

REG_INT2_CFG

Enum H3LIS331DL_REG_T

REG_INT2_SRC

Enum H3LIS331DL_REG_T

REG_INT2_THS

Enum H3LIS331DL_REG_T

REG_INT2_DUR

Enum H3LIS331DL_REG_T

REG1_XEN

Enum REG1_BITS_T

REG1_YEN

Enum REG1_BITS_T

REG1_ZEN

Enum REG1_BITS_T

REG1_DR0

Enum REG1_BITS_T

REG1_DR1

Enum REG1_BITS_T

REG1_DR_SHIFT

Enum REG1_BITS_T

REG1_PM0

Enum REG1_BITS_T

REG1_PM1

Enum REG1_BITS_T

REG1_PM2

Enum REG1_BITS_T

REG1_PM_SHIFT

Enum REG1_BITS_T

DR_50_37

Enum DR_BITS_T

DR_100_74

Enum DR_BITS_T

DR_400_292

Enum DR_BITS_T

DR_1000_780

Enum DR_BITS_T

PM_POWERDWN

Enum PM_BITS_T

PM_NORMAL

Enum PM_BITS_T

PM_LP05

Enum PM_BITS_T

PM_LP1

Enum PM_BITS_T

PM_LP2

Enum PM_BITS_T

PM_LP5

Enum PM_BITS_T

PM_LP10

Enum PM_BITS_T

REG2_HPCF0

Enum REG2_BITS_T

REG2_HPCF1

Enum REG2_BITS_T

REG2_HPCF_SHIFT

Enum REG2_BITS_T

REG2_HPEN1

Enum REG2_BITS_T

REG2_HPEN2

Enum REG2_BITS_T

REG2_FDS

Enum REG2_BITS_T

REG2_HPM0

Enum REG2_BITS_T

REG2_HPM1

Enum REG2_BITS_T

REG2_HPM_SHIFT

Enum REG2_BITS_T

REG2_BOOT

Enum REG2_BITS_T

HPCF_8

Enum HPCF_BITS_T

HPCF_16

Enum HPCF_BITS_T

HPCF_32

Enum HPCF_BITS_T

HPCF_64

Enum HPCF_BITS_T

HPM_NORMAL0

Enum HPM_BITS_T

HPM_REF

Enum HPM_BITS_T

HPM_NORMAL1

Enum HPM_BITS_T

REG3_I1_CFG0

Enum REG3_BITS_T

REG3_I1_CFG1

Enum REG3_BITS_T

REG3_I1_CFG_SHIFT

Enum REG3_BITS_T

REG3_LIR1

Enum REG3_BITS_T

REG3_I2_CFG0

Enum REG3_BITS_T

REG3_I2_CFG1

Enum REG3_BITS_T

REG3_I2_CFG_SHIFT

Enum REG3_BITS_T

REG3_LIR2

Enum REG3_BITS_T

REG3_PP_OD

Enum REG3_BITS_T

REG3_IHL

Enum REG3_BITS_T

I_SRC

Enum I_CFG_BITS_T

I_OR

Enum I_CFG_BITS_T

I_DR

Enum I_CFG_BITS_T

I_BOOTING

Enum I_CFG_BITS_T

REG4_SIM

Enum REG4_BITS_T

REG4_FS0

Enum REG4_BITS_T

REG4_FS1

Enum REG4_BITS_T

REG4_FS_SHIFT

Enum REG4_BITS_T

REG4_BLE

Enum REG4_BITS_T

REG4_BDU

Enum REG4_BITS_T

FS_100

Enum FS_BITS_T

FS_200

Enum FS_BITS_T

FS_400

Enum FS_BITS_T

REG5_TURNON0

Enum REG5_BITS_T

REG5_TURNON1

Enum REG5_BITS_T

STATUS_XDA

Enum STATUS_BITS_T

STATUS_YDA

Enum STATUS_BITS_T

STATUS_ZDA

Enum STATUS_BITS_T

STATUS_ZYXDA

Enum STATUS_BITS_T

STATUS_XOR

Enum STATUS_BITS_T

STATUS_YOR

Enum STATUS_BITS_T

STATUS_ZOR

Enum STATUS_BITS_T

STATUS_ZYXOR

Enum STATUS_BITS_T

INT_CFG_XLIE

Enum INT_CFG_BITS_T

INT_CFG_XHIE

Enum INT_CFG_BITS_T

INT_CFG_YLIE

Enum INT_CFG_BITS_T

INT_CFG_YHIE

Enum INT_CFG_BITS_T

INT_CFG_ZLIE

Enum INT_CFG_BITS_T

INT_CFG_ZHIE

Enum INT_CFG_BITS_T

INT_CFG_AOI

Enum INT_CFG_BITS_T

INT_SRC_XL

Enum INT_SRC_BITS_T

INT_SRC_XH

Enum INT_SRC_BITS_T

INT_SRC_YL

Enum INT_SRC_BITS_T

INT_SRC_YH

Enum INT_SRC_BITS_T

INT_SRC_ZL

Enum INT_SRC_BITS_T

INT_SRC_ZH

Enum INT_SRC_BITS_T

INT_SRC_IA

Enum INT_SRC_BITS_T