upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Classes | Public Member Functions | List of all members

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

Detailed Description

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

h3lis331dl.jpg
int[] val;
float[] accel;
// Instantiate an H3LIS331DL on I2C bus 0
// Initialize the device with default values
sensor.init();
while(true){
sensor.update();
val = sensor.getRawXYZ();
System.out.println( "Raw: X: " + val[0] + " Y: " + val[1] + " Z: " + val[2] );
accel = sensor.getAcceleration();
System.out.println( "Acceleration: X: " + accel[0] + " Y: " + accel[1] + " Z: " + accel[2] );
Thread.sleep(1000);
}

Classes

class  DR_BITS_T
 
class  FS_BITS_T
 
class  H3LIS331DL_REG_T
 
class  HPCF_BITS_T
 
class  HPM_BITS_T
 
class  I_CFG_BITS_T
 
class  INT_CFG_BITS_T
 
class  INT_SRC_BITS_T
 
class  PM_BITS_T
 
class  REG1_BITS_T
 
class  REG2_BITS_T
 
class  REG3_BITS_T
 
class  REG4_BITS_T
 
class  REG5_BITS_T
 
class  STATUS_BITS_T
 

Public Member Functions

synchronized void delete ()
 
 H3LIS331DL (int bus, short address)
 
 H3LIS331DL (int bus)
 
boolean init (H3LIS331DL.DR_BITS_T odr, H3LIS331DL.PM_BITS_T pm, H3LIS331DL.FS_BITS_T fs)
 
boolean init (H3LIS331DL.DR_BITS_T odr, H3LIS331DL.PM_BITS_T pm)
 
boolean init (H3LIS331DL.DR_BITS_T odr)
 
boolean init ()
 
short getChipID ()
 
boolean setDataRate (H3LIS331DL.DR_BITS_T odr)
 
boolean setPowerMode (H3LIS331DL.PM_BITS_T pm)
 
boolean enableAxis (short axisEnable)
 
boolean setFullScale (H3LIS331DL.FS_BITS_T fs)
 
boolean setHPCF (H3LIS331DL.HPCF_BITS_T val)
 
boolean setHPM (H3LIS331DL.HPM_BITS_T val)
 
boolean boot ()
 
boolean enableHPF1 (boolean enable)
 
boolean enableHPF2 (boolean enable)
 
boolean enableFDS (boolean enable)
 
boolean setInterruptActiveLow (boolean enable)
 
boolean setInterruptOpenDrain (boolean enable)
 
boolean setInterrupt1Latch (boolean enable)
 
boolean setInterrupt2Latch (boolean enable)
 
boolean setInterrupt1PadConfig (H3LIS331DL.I_CFG_BITS_T val)
 
boolean setInterrupt2PadConfig (H3LIS331DL.I_CFG_BITS_T val)
 
boolean enableBDU (boolean enable)
 
boolean enableBLE (boolean enable)
 
boolean enableSleepToWake (boolean enable)
 
short getStatus ()
 
boolean setInterrupt1Config (short val)
 
boolean setInterrupt2Config (short val)
 
boolean setInterrupt1Source (short val)
 
boolean setInterrupt2Source (short val)
 
boolean setInterrupt1Threshold (short val)
 
boolean setInterrupt2Threshold (short val)
 
boolean setInterrupt1Duration (short val)
 
boolean setInterrupt2Duration (short val)
 
void update ()
 
void setAdjustmentOffsets (int adjX, int adjY, int adjZ)
 
float[] getAcceleration ()
 
int[] getRawXYZ ()
 
int[] getXYZ ()
 

Constructor & Destructor Documentation

H3LIS331DL ( int  bus,
short  address 
)

H3LIS331DL constructor

Parameters
busI2C bus to use
addressAddress for this device

Member Function Documentation

boolean 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.

Returns
True if successful
boolean enableAxis ( short  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.

Parameters
axisEnableBitmask of axes to enable (REG1_XEN | REG1_YEN | REG1_ZEN)
Returns
True if successful
boolean enableBDU ( boolean  enable)

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

Parameters
enableTrue to enable, false otherwise
Returns
True if successful
boolean enableBLE ( boolean  enable)

Enables big-endian output for 16b reads

Parameters
enableTrue to enable, false otherwise
Returns
True if successful
boolean enableFDS ( boolean  enable)

Enables filtered data selection

Parameters
enableTrue to enable, false otherwise
Returns
True if successful
boolean enableHPF1 ( boolean  enable)

Enables a high-pass filter for interrupt 1 source

Parameters
enableTrue to enable the filter, false otherwise
Returns
True if successful
boolean enableHPF2 ( boolean  enable)

Enables a high-pass filter for interrupt 2 source

Parameters
enableTrue to enable the filter, false otherwise
Returns
True if successful
boolean enableSleepToWake ( boolean  enable)

Enables sleep-to-wake functionality

Parameters
enableTrue to enable, false otherwise
Returns
True if successful
float [] getAcceleration ( )

Gets acceleration values for each of the axes

Returns
Array containing X, Y, Z acceleration values
short getChipID ( )

Reads and returns the chip ID (WHO_AM_I register)

Returns
True if successful
int [] getRawXYZ ( )

Gets raw axis values

Returns
Array containing X, Y, Z raw values
short getStatus ( )

Returns the contents of the REG_STATUS register

Returns
Contents of the REG_STATUS register
int [] getXYZ ( )

Gets adjusted axis values

Returns
Array containing X, Y, Z adjusted axis values
boolean init ( H3LIS331DL.DR_BITS_T  odr,
H3LIS331DL.PM_BITS_T  pm,
H3LIS331DL.FS_BITS_T  fs 
)

Sets up initial values and starts operation

Parameters
odrData rate: one of the DR_BITS_T values
pmPower mode: one of the PM_BITS_T values
fsFullScale: one of the FS_BITS_T values
Returns
True if successful
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.

Parameters
adjXAmount by which to correct the X-axis measurement
adjYAmount by which to correct the Y-axis measurement
adjZAmount by which to correct the Z-axis measurement
boolean setDataRate ( H3LIS331DL.DR_BITS_T  odr)

Sets the output data rate

Parameters
Oneof the DR_BITS_T values
Returns
True if successful
boolean setFullScale ( H3LIS331DL.FS_BITS_T  fs)

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

Parameters
fsOne of the FS_BITS_T values
Returns
True if successful
boolean setHPCF ( H3LIS331DL.HPCF_BITS_T  val)

Sets a high-pass cutoff filter

Parameters
valOne of the HPCF_BITS_T values
Returns
True if successful
boolean setHPM ( H3LIS331DL.HPM_BITS_T  val)

Sets a high-pass filter mode

Parameters
valOne of the HPM_BITS_T values
Returns
True if successful
boolean setInterrupt1Config ( short  val)

Sets up the interrupt 1 config register

Parameters
valBitmask of desired INT_CFG_BITS_T bits
Returns
True if successful
boolean setInterrupt1Duration ( short  val)

Sets up the interrupt 1 duration register

Parameters
valDuration to set
Returns
True if successful
boolean setInterrupt1Latch ( boolean  enable)

Enables interrupt 1 latch

Parameters
enableTrue to enable, false otherwise
Returns
True if successful
boolean setInterrupt1PadConfig ( H3LIS331DL.I_CFG_BITS_T  val)

Sets the interrupt 1 pad configuration

Parameters
valOne fo the I_CFG_BITS_T values
Returns
True if successful
boolean setInterrupt1Source ( short  val)

Sets up the interrupt 1 source register

Parameters
valBitmask of desired INT_SRC_BITS_T bits
Returns
True if successful
boolean setInterrupt1Threshold ( short  val)

Sets up the interrupt 1 threshold register

Parameters
valThreshhold to set
Returns
True if successful
boolean setInterrupt2Config ( short  val)

Sets up the interrupt 2 config register

Parameters
valBitmask of desired INT_CFG_BITS_T bits
Returns
True if successful
boolean setInterrupt2Duration ( short  val)

Sets up the interrupt 2 duration register

Parameters
valDuration to set
Returns
True if successful
boolean setInterrupt2Latch ( boolean  enable)

Enables interrupt 2 latch

Parameters
enableTrue to enable, false otherwise
Returns
True if successful
boolean setInterrupt2PadConfig ( H3LIS331DL.I_CFG_BITS_T  val)

Sets the interrupt 2 pad configuration

Parameters
valOne fo the I_CFG_BITS_T values
Returns
True if successful
boolean setInterrupt2Source ( short  val)

Sets up the interrupt 2 source register

Parameters
valBitmask of desired INT_SRC_BITS_T bits
Returns
True if successful
boolean setInterrupt2Threshold ( short  val)

Sets up the interrupt 2 threshold register

Parameters
valThreshhold to set
Returns
True if successful
boolean setInterruptActiveLow ( boolean  enable)

Sets interrupts to be active low instead of high

Parameters
enableTrue to enable, false otherwise
Returns
True if successful
boolean setInterruptOpenDrain ( boolean  enable)

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

Parameters
enableTrue to enable, false otherwise
Returns
True if successful
boolean setPowerMode ( H3LIS331DL.PM_BITS_T  pm)

Sets the power mode

Parameters
Oneof the PM_BITS_T values
Returns
True if successful
void update ( )

Reads the sensor and stores current values internally


The documentation for this class was generated from the following file: