Adafruit LPS35HW Library
Adafruit_LPS35HW.h
Go to the documentation of this file.
1 
17 #ifndef _ADAFRUIT_LPS35HW_H
18 #define _ADAFRUIT_LPS35HW_H
19 
20 #include "Arduino.h"
21 #include <Adafruit_BusIO_Register.h>
22 #include <Adafruit_I2CDevice.h>
23 #include <Wire.h>
24 
25 #define LPS35HW_I2CADDR_DEFAULT 0x5D
26 #define LPS35HW_INTERRUPT_CFG 0x0B
27 #define LPS35HW_THS_P_L 0x0C
28 #define LPS35HW_THS_P_H 0x0D
29 #define LPS35HW_WHO_AM_I 0x0F
30 #define LPS35HW_CTRL_REG1 0x10
31 #define LPS35HW_CTRL_REG2 0x11
32 #define LPS35HW_CTRL_REG3 0x12
33 #define LPS35HW_FIFO_CTRL 0x14
34 #define LPS35HW_REF_P_XL 0x15
35 #define LPS35HW_REF_P_L 0x16
36 #define LPS35HW_REF_P_H 0x17
37 #define LPS35HW_RPDS_L 0x18
38 #define LPS35HW_RPDS_H 0x19
39 #define LPS35HW_RES_CONF 0x1A
40 #define LPS35HW_INT_SOURCE 0x25
41 #define LPS35HW_FIFO_STATUS 0x26
42 #define LPS35HW_STATUS 0x27
43 #define LPS35HW_PRESS_OUT_XL 0x28
44 #define LPS35HW_PRESS_OUT_L 0x29
45 #define LPS35HW_PRESS_OUT_H 0x2A
46 #define LPS35HW_TEMP_OUT_L 0x2B
47 #define LPS35HW_TEMP_OUT_H 0x2C
48 #define LPS35HW_LPFP_RES 0x33
49 
50 
55 typedef enum _data_rate {
59  LPS35HW_RATE_1_HZ,
65 
71 public:
73  boolean begin_I2C(uint8_t i2c_addr = LPS35HW_I2CADDR_DEFAULT,
74  TwoWire *wire = &Wire);
75  boolean begin_SPI(uint8_t cs_pin, SPIClass *theSPI = &SPI);
76  boolean begin_SPI(int8_t cs_pin, int8_t sck_pin, int8_t miso_pin,
77  int8_t mosi_pin);
78  void reset(void);
79  float readTemperature(void);
80  float readPressure(void);
81  void setDataRate(LPS35HW_DataRate new_rate);
82  void takeMeasurement(void);
83  void zeroPressure(void);
84  void resetPressure(void);
85  void setThresholdPressure(float threshold_pressure);
86  void enableHighThreshold(void);
87  void enableLowThreshold(void);
88  bool highThresholdExceeded(void);
89  bool lowThresholdExceeded(void);
90  void enableInterrupts(bool active_low = false, bool open_drain = false);
91  void disableInterrupts(void);
92  void enableLowPass(bool extra_low_bandwidth = false);
93 
94  Adafruit_BusIO_Register *Config1,
95  *Config2,
96  *Config3,
97  *InterruptCfg,
99 
100 private:
101  bool _init(void);
102 
103  Adafruit_I2CDevice *i2c_dev;
104  Adafruit_SPIDevice *spi_dev;
105 };
106 
107 #endif
bool lowThresholdExceeded(void)
Returns the current state of the low pressure threshold interrupt.
Definition: Adafruit_LPS35HW.cpp:322
_data_rate
Data rate options.
Definition: Adafruit_LPS35HW.h:55
bool highThresholdExceeded(void)
Returns the current state of the high pressure threshold interrupt.
Definition: Adafruit_LPS35HW.cpp:312
void setDataRate(LPS35HW_DataRate new_rate)
Sets a new measurement rate.
Definition: Adafruit_LPS35HW.cpp:332
Definition: Adafruit_LPS35HW.h:56
Definition: Adafruit_LPS35HW.h:63
Adafruit_BusIO_Register * Config2
BusIO Register for CONFIG_2.
Definition: Adafruit_LPS35HW.h:94
Definition: Adafruit_LPS35HW.h:62
Adafruit_LPS35HW()
Instantiates a new LPS35HW class.
Definition: Adafruit_LPS35HW.cpp:43
void disableInterrupts(void)
Disables pressure threshold interrupts.
Definition: Adafruit_LPS35HW.cpp:287
boolean begin_I2C(uint8_t i2c_addr=LPS35HW_I2CADDR_DEFAULT, TwoWire *wire=&Wire)
Sets up the hardware and initializes I2C.
Definition: Adafruit_LPS35HW.cpp:53
Definition: Adafruit_LPS35HW.h:61
void resetPressure(void)
Resets the reference pressure to zero so calls to getPressure are reported as the absolute value...
Definition: Adafruit_LPS35HW.cpp:218
Adafruit_BusIO_Register * InterruptCfg
BusIO Register for INTERRUPT_CFG.
Definition: Adafruit_LPS35HW.h:94
enum _data_rate LPS35HW_DataRate
Data rate options.
void takeMeasurement(void)
Takes a new measurement while in one shot mode.
Definition: Adafruit_LPS35HW.cpp:187
void enableInterrupts(bool active_low=false, bool open_drain=false)
Enables pressure threshold interrupts. High and low thresholds need to be enabled individually with e...
Definition: Adafruit_LPS35HW.cpp:273
void zeroPressure(void)
Sets the reference temperature to the current temperature. Future pressure readings will be relative ...
Definition: Adafruit_LPS35HW.cpp:203
void enableLowPass(bool extra_low_bandwidth=false)
Enables the low pass filter with ODR/9 bandwidth.
Definition: Adafruit_LPS35HW.cpp:299
float readPressure(void)
Reads and scales the value of the pressure register.
Definition: Adafruit_LPS35HW.cpp:170
void setThresholdPressure(float threshold_pressure)
Sets the pressure threshold used by the high and low pressure thresholds.
Definition: Adafruit_LPS35HW.cpp:232
Adafruit_BusIO_Register * Config1
BusIO Register for CONFIG_1.
Definition: Adafruit_LPS35HW.h:94
Class that stores state and functions for interacting with LPS35HW Current and Power Sensor...
Definition: Adafruit_LPS35HW.h:70
boolean begin_SPI(uint8_t cs_pin, SPIClass *theSPI=&SPI)
Sets up the hardware and initializes hardware SPI.
Definition: Adafruit_LPS35HW.cpp:70
void enableLowThreshold(void)
Disables low pressure threshold interrupts.
Definition: Adafruit_LPS35HW.cpp:255
float readTemperature(void)
Reads and scales the current value of the temperature register.
Definition: Adafruit_LPS35HW.cpp:159
void enableHighThreshold(void)
Enables high pressure threshold interrupts.
Definition: Adafruit_LPS35HW.cpp:242
#define LPS35HW_I2CADDR_DEFAULT
LPS35HW default i2c address.
Definition: Adafruit_LPS35HW.h:25
Adafruit_BusIO_Register * Config3
BusIO Register for CONFIG_3.
Definition: Adafruit_LPS35HW.h:94
void reset(void)
Resets the hardware. All configuration registers are set to default values, the same as a power-on re...
Definition: Adafruit_LPS35HW.cpp:145
Adafruit_BusIO_Register * InterruptStatus
BusIO Register for INTERRUPT_STATUS.
Definition: Adafruit_LPS35HW.h:94
Definition: Adafruit_LPS35HW.h:60