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

API for the HP20X-based Grove Barometer (High-Accuracy) More...

Detailed Description

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.

hp20x.jpg

Classes

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
 

Public Member Functions

synchronized void delete ()
 
 HP20X (int bus, short address)
 
 HP20X (int bus)
 
boolean init (HP20X.DSR_BITS_T dsr)
 
boolean init ()
 
boolean writeCmd (short cmd)
 
boolean writeReg (HP20X.HP20X_REG_T reg, short data)
 
short readReg (HP20X.HP20X_REG_T reg)
 
int readData ()
 
boolean isReady ()
 
boolean waitforDeviceReady ()
 
float getTemperature ()
 
float getPressure ()
 
float getAltitude ()
 
void compensationEnable (boolean enable)
 
boolean setInterruptEnable (short bits)
 
boolean setInterruptConfig (short bits)
 
short getInterruptSource ()
 
void setDSR (HP20X.DSR_BITS_T dsr)
 
void recalibrateInternal ()
 
void softReset ()
 
void setAltitudeOffset (short off)
 
void setPAThreshholds (short low, short med, short high)
 
void setTemperatureThreshholds (byte low, byte med, byte high)
 

Constructor & Destructor Documentation

HP20X ( int  bus,
short  address 
)

HP20X constructor

Parameters
busI2C bus to use
addressAddress for this device

Member Function Documentation

void compensationEnable ( boolean  enable)

Enables or disables the on-chip compensator. This allows the chip to filter and clean up the output data.

Parameters
enableTrue to enable, false otherwise
float getAltitude ( )

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
float getPressure ( )

Returns the pressure in millibars

Returns
Pressure
float getTemperature ( )

Returns the temperature in Celsius

Returns
Temperature
boolean init ( HP20X.DSR_BITS_T  dsr)

Sets up initial values and starts operation

Parameters
dsrData sampling rate; one of the DSR_BITS_T values
Returns
True if successful
boolean isReady ( )

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
int readData ( )

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
regRegister 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
offOffset
void setDSR ( HP20X.DSR_BITS_T  dsr)

Sets the data sampling rate. Higher rates are more precise, but take more time per measurement.

Parameters
dsrOne 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
bitsOne 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
bitsOne 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
lowLow threshold to generate an interrupt
medMedium threshold to generate an interrupt
highHigh threshold to generate an interrupt
void setTemperatureThreshholds ( byte  low,
byte  med,
byte  high 
)

Sets temperature thresholds for interrupt generation

Parameters
lowLow threshold to generate an interrupt
medMedium threshold to generate an interrupt
highHigh threshold to generate an interrupt
void softReset ( )

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
cmdCommand 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
regRegister to write to; one of the HP20X_REG_T values
dataValue to write
Returns
True if successful

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