API for the H3LIS331DL-based Grove 3-Axis Digital Accelerometer (400g)
More...
This is a high-performance, high-range accelerometer for extreme applications.
int[] val;
float[] accel;
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);
}
|
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 |
|
H3LIS331DL constructor
- Parameters
-
bus | I2C bus to use |
address | Address for this device |
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
-
axisEnable | Bitmask 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
-
enable | True to enable, false otherwise |
- Returns
- True if successful
boolean enableBLE |
( |
boolean |
enable | ) |
|
Enables big-endian output for 16b reads
- Parameters
-
enable | True to enable, false otherwise |
- Returns
- True if successful
boolean enableFDS |
( |
boolean |
enable | ) |
|
Enables filtered data selection
- Parameters
-
enable | True to enable, false otherwise |
- Returns
- True if successful
boolean enableHPF1 |
( |
boolean |
enable | ) |
|
Enables a high-pass filter for interrupt 1 source
- Parameters
-
enable | True to enable the filter, false otherwise |
- Returns
- True if successful
boolean enableHPF2 |
( |
boolean |
enable | ) |
|
Enables a high-pass filter for interrupt 2 source
- Parameters
-
enable | True to enable the filter, false otherwise |
- Returns
- True if successful
boolean enableSleepToWake |
( |
boolean |
enable | ) |
|
Enables sleep-to-wake functionality
- Parameters
-
enable | True 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
Reads and returns the chip ID (WHO_AM_I register)
- Returns
- True if successful
Gets raw axis values
- Returns
- Array containing X, Y, Z raw values
Returns the contents of the REG_STATUS register
- Returns
- Contents of the REG_STATUS register
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
-
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 |
- 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
-
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 |
boolean setDataRate |
( |
H3LIS331DL.DR_BITS_T |
odr | ) |
|
Sets the output data rate
- Parameters
-
One | of 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
-
fs | One of the FS_BITS_T values |
- Returns
- True if successful
boolean setHPCF |
( |
H3LIS331DL.HPCF_BITS_T |
val | ) |
|
Sets a high-pass cutoff filter
- Parameters
-
val | One of the HPCF_BITS_T values |
- Returns
- True if successful
boolean setHPM |
( |
H3LIS331DL.HPM_BITS_T |
val | ) |
|
Sets a high-pass filter mode
- Parameters
-
val | One of the HPM_BITS_T values |
- Returns
- True if successful
boolean setInterrupt1Config |
( |
short |
val | ) |
|
Sets up the interrupt 1 config register
- Parameters
-
val | Bitmask of desired INT_CFG_BITS_T bits |
- Returns
- True if successful
boolean setInterrupt1Duration |
( |
short |
val | ) |
|
Sets up the interrupt 1 duration register
- Parameters
-
- Returns
- True if successful
boolean setInterrupt1Latch |
( |
boolean |
enable | ) |
|
Enables interrupt 1 latch
- Parameters
-
enable | True to enable, false otherwise |
- Returns
- True if successful
boolean setInterrupt1PadConfig |
( |
H3LIS331DL.I_CFG_BITS_T |
val | ) |
|
Sets the interrupt 1 pad configuration
- Parameters
-
val | One fo the I_CFG_BITS_T values |
- Returns
- True if successful
boolean setInterrupt1Source |
( |
short |
val | ) |
|
Sets up the interrupt 1 source register
- Parameters
-
val | Bitmask of desired INT_SRC_BITS_T bits |
- Returns
- True if successful
boolean setInterrupt1Threshold |
( |
short |
val | ) |
|
Sets up the interrupt 1 threshold register
- Parameters
-
- Returns
- True if successful
boolean setInterrupt2Config |
( |
short |
val | ) |
|
Sets up the interrupt 2 config register
- Parameters
-
val | Bitmask of desired INT_CFG_BITS_T bits |
- Returns
- True if successful
boolean setInterrupt2Duration |
( |
short |
val | ) |
|
Sets up the interrupt 2 duration register
- Parameters
-
- Returns
- True if successful
boolean setInterrupt2Latch |
( |
boolean |
enable | ) |
|
Enables interrupt 2 latch
- Parameters
-
enable | True to enable, false otherwise |
- Returns
- True if successful
boolean setInterrupt2PadConfig |
( |
H3LIS331DL.I_CFG_BITS_T |
val | ) |
|
Sets the interrupt 2 pad configuration
- Parameters
-
val | One fo the I_CFG_BITS_T values |
- Returns
- True if successful
boolean setInterrupt2Source |
( |
short |
val | ) |
|
Sets up the interrupt 2 source register
- Parameters
-
val | Bitmask of desired INT_SRC_BITS_T bits |
- Returns
- True if successful
boolean setInterrupt2Threshold |
( |
short |
val | ) |
|
Sets up the interrupt 2 threshold register
- Parameters
-
- Returns
- True if successful
boolean setInterruptActiveLow |
( |
boolean |
enable | ) |
|
Sets interrupts to be active low instead of high
- Parameters
-
enable | True 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
-
enable | True to enable, false otherwise |
- Returns
- True if successful
boolean setPowerMode |
( |
H3LIS331DL.PM_BITS_T |
pm | ) |
|
Sets the power mode
- Parameters
-
One | of the PM_BITS_T values |
- Returns
- True if successful
Reads the sensor and stores current values internally
The documentation for this class was generated from the following file:
- /var/lib/jenkins/workspace/upm-doc-stable/build-33/src/h3lis331dl/H3LIS331DL.java