API for the HP20X-based Grove Barometer (High-Accuracy)
More...
This is a high-accuracy barometer providing pressure, altitude, and temperature data. It can be calibrated for a given altitude offset, and a wide range of interrupt generating capabilities are supported. As usual, see the HP20X datasheet for more details.
This module was developed using a Grove Barometer (High-Accuracy) based on an HP206C chip.
|
class | CHNL_BITS_T |
|
class | DSR_BITS_T |
|
class | HP20X_CMD_T |
|
class | HP20X_REG_T |
|
class | INT_CFG_BITS_T |
|
class | INT_EN_BITS_T |
|
class | INT_SRC_BITS_T |
|
class | PARA_BITS_T |
|
HP20X |
( |
int |
bus, |
|
|
short |
address |
|
) |
| |
HP20X constructor
- Parameters
-
bus | I2C bus to use |
address | Address for this device |
void compensationEnable |
( |
boolean |
enable | ) |
|
Enables or disables the on-chip compensator. This allows the chip to filter and clean up the output data.
- Parameters
-
enable | True to enable, false otherwise |
Returns the computed altitude in meters
- Returns
- Altitude
short getInterruptSource |
( |
| ) |
|
Gets the interrupt source register. This register indicates which interrupts have been triggered. In addition, it indicates when certain operations have been completed.
- Returns
- One of more of the INT_SRC_BITS_T values
Returns the pressure in millibars
- Returns
- Pressure
Returns the temperature in Celsius
- Returns
- Temperature
boolean init |
( |
HP20X.DSR_BITS_T |
dsr | ) |
|
Sets up initial values and starts operation
- Parameters
-
dsr | Data sampling rate; one of the DSR_BITS_T values |
- Returns
- True if successful
Checks to see if the DR_RDY bit is set, indicating the device can accept commands
- Returns
- True if the device is ready, false otherwise
Reads 3 bytes of data in response to a conversion request, and converts it to an integer
- Returns
- Value read back (temperature, pressure, etc.)
short readReg |
( |
HP20X.HP20X_REG_T |
reg | ) |
|
Reads a register and returns its value
- Parameters
-
reg | Register to read; one of the HP20X_REG_T values |
- Returns
- Value of a specified register
void recalibrateInternal |
( |
| ) |
|
Starts an internal recalibration of analog blocks. This is faster than a soft reset.
void setAltitudeOffset |
( |
short |
off | ) |
|
Sets the altitude offset for your region. See the datasheet for more details. Setting this correctly for your region is required for accurate altitude data.
- Parameters
-
void setDSR |
( |
HP20X.DSR_BITS_T |
dsr | ) |
|
Sets the data sampling rate. Higher rates are more precise, but take more time per measurement.
- Parameters
-
dsr | One of the DSR_BITS_T values |
boolean setInterruptConfig |
( |
short |
bits | ) |
|
Sets up the interrupt configuration register. This register defines which events can cause an interrupt to be indicated.
- Parameters
-
bits | One or more of the INT_EN_BITS_T bits |
- Returns
- True if successful, false otherwise
boolean setInterruptEnable |
( |
short |
bits | ) |
|
Sets up the interrupt enable register. This register defines which events can cause a hardware interrupt pin to be pulled high (active).
- Parameters
-
bits | One or more of the INT_EN_BITS_T bits |
- Returns
- True if successful, false otherwise
void setPAThreshholds |
( |
short |
low, |
|
|
short |
med, |
|
|
short |
high |
|
) |
| |
Sets pressure/altitude thresholds for interrupt generation
- Parameters
-
low | Low threshold to generate an interrupt |
med | Medium threshold to generate an interrupt |
high | High threshold to generate an interrupt |
void setTemperatureThreshholds |
( |
byte |
low, |
|
|
byte |
med, |
|
|
byte |
high |
|
) |
| |
Sets temperature thresholds for interrupt generation
- Parameters
-
low | Low threshold to generate an interrupt |
med | Medium threshold to generate an interrupt |
high | High threshold to generate an interrupt |
Executes a soft reset. All register values are reset to power-on defaults. This function returns when the reset is complete and the device reports it is ready.
boolean waitforDeviceReady |
( |
| ) |
|
Checks to see if the device is ready, and sleeps/retries if not. Returns once the device indicates it's ready.
- Returns
- True if the device is ready; false if retries are exhausted
boolean writeCmd |
( |
short |
cmd | ) |
|
Sends a command to the device
- Parameters
-
cmd | Command to send; usually, one of the HP20X_CMD_T values |
- Returns
- True if successful
boolean writeReg |
( |
HP20X.HP20X_REG_T |
reg, |
|
|
short |
data |
|
) |
| |
Writes a value to a register
- Parameters
-
reg | Register to write to; one of the HP20X_REG_T values |
data | Value to write |
- Returns
- True if successful
The documentation for this class was generated from the following file:
- /var/lib/jenkins/workspace/upm-doc-stable/build-33/src/hp20x/HP20X.java