-
Notifications
You must be signed in to change notification settings - Fork 0
/
Adafruit_MPRLS_AllThumbs.h
58 lines (49 loc) · 1.72 KB
/
Adafruit_MPRLS_AllThumbs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*!
* @file Adafruit_MPRLS.h
*
* Designed specifically to work with the MPRLS sensors from Adafruit
* ----> https://www.adafruit.com/products/3965
*
* These sensors use I2C to communicate, 2 pins (SCL+SDA) are required
* to interface with the breakout.
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Written by Limor Fried/Ladyada for Adafruit Industries.
*
* MIT license, all text here must be included in any redistribution.
*
*/
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "Wire.h"
#define MPRLS_DEFAULT_ADDR (0x18) ///< Most common I2C address
#define MPRLS_STATUS_POWERED (0x40) ///< Status SPI powered bit
#define MPRLS_STATUS_BUSY (0x20) ///< Status busy bit
#define MPRLS_STATUS_FAILED (0x04) ///< Status bit for integrity fail
#define MPRLS_STATUS_MATHSAT (0x01) ///< Status bit for math saturation
/**************************************************************************/
/*!
@brief Class that stores state and functions for interacting with MPRLS sensor IC
*/
/**************************************************************************/
class Adafruit_MPRLS {
public:
Adafruit_MPRLS(int8_t reset_pin = -1, int8_t EOC_pin = -1,
uint8_t PSI_min = 0, uint8_t PSI_max = 25);
boolean begin(uint8_t i2c_addr = MPRLS_DEFAULT_ADDR,
TwoWire *twoWire = &Wire);
uint8_t readStatus(void);
float readPressure(void);
private:
uint32_t readData(void);
uint8_t _i2c_addr;
int8_t _reset, _eoc;
uint8_t _PSI_min, _PSI_max;
TwoWire *_i2c;
};