Adafruit MPR121 Library
Adafruit_MPR121.h
Go to the documentation of this file.
1 
22 #ifndef ADAFRUIT_MPR121_H
23 #define ADAFRUIT_MPR121_H
24 
25 #include "Arduino.h"
26 #include <Adafruit_BusIO_Register.h>
27 #include <Adafruit_I2CDevice.h>
28 
29 // The default I2C address
30 #define MPR121_I2CADDR_DEFAULT 0x5A
31 #define MPR121_TOUCH_THRESHOLD_DEFAULT 12
32 #define MPR121_RELEASE_THRESHOLD_DEFAULT 6
33 
34 
37 enum {
38  MPR121_TOUCHSTATUS_L = 0x00,
39  MPR121_TOUCHSTATUS_H = 0x01,
40  MPR121_FILTDATA_0L = 0x04,
41  MPR121_FILTDATA_0H = 0x05,
42  MPR121_BASELINE_0 = 0x1E,
43  MPR121_MHDR = 0x2B,
44  MPR121_NHDR = 0x2C,
45  MPR121_NCLR = 0x2D,
46  MPR121_FDLR = 0x2E,
47  MPR121_MHDF = 0x2F,
48  MPR121_NHDF = 0x30,
49  MPR121_NCLF = 0x31,
50  MPR121_FDLF = 0x32,
51  MPR121_NHDT = 0x33,
52  MPR121_NCLT = 0x34,
53  MPR121_FDLT = 0x35,
54 
55  MPR121_TOUCHTH_0 = 0x41,
56  MPR121_RELEASETH_0 = 0x42,
57  MPR121_DEBOUNCE = 0x5B,
58  MPR121_CONFIG1 = 0x5C,
59  MPR121_CONFIG2 = 0x5D,
60  MPR121_CHARGECURR_0 = 0x5F,
61  MPR121_CHARGETIME_1 = 0x6C,
62  MPR121_ECR = 0x5E,
63  MPR121_AUTOCONFIG0 = 0x7B,
64  MPR121_AUTOCONFIG1 = 0x7C,
65  MPR121_UPLIMIT = 0x7D,
66  MPR121_LOWLIMIT = 0x7E,
67  MPR121_TARGETLIMIT = 0x7F,
68 
69  MPR121_GPIODIR = 0x76,
70  MPR121_GPIOEN = 0x77,
71  MPR121_GPIOSET = 0x78,
72  MPR121_GPIOCLR = 0x79,
73  MPR121_GPIOTOGGLE = 0x7A,
74 
75  MPR121_SOFTRESET = 0x80,
76 };
77 
78 //.. thru to 0x1C/0x1D
79 
85 public:
86  // Hardware I2C
88 
89  bool begin(uint8_t i2caddr = MPR121_I2CADDR_DEFAULT, TwoWire *theWire = &Wire,
90  uint8_t touchThreshold = MPR121_TOUCH_THRESHOLD_DEFAULT,
91  uint8_t releaseThreshold = MPR121_RELEASE_THRESHOLD_DEFAULT);
92 
93  uint16_t filteredData(uint8_t t);
94  uint16_t baselineData(uint8_t t);
95 
96  uint8_t readRegister8(uint8_t reg);
97  uint16_t readRegister16(uint8_t reg);
98  void writeRegister(uint8_t reg, uint8_t value);
99  uint16_t touched(void);
100  // Add deprecated attribute so that the compiler shows a warning
101  void setThreshholds(uint8_t touch, uint8_t release)
102  __attribute__((deprecated));
103  void setThresholds(uint8_t touch, uint8_t release);
104 
105 private:
106  Adafruit_I2CDevice *i2c_dev = NULL;
107 };
108 
109 #endif
uint16_t baselineData(uint8_t t)
Read the baseline value for the channel. The 3rd level filtered result is internally 10bit but only h...
Definition: Adafruit_MPR121.cpp:176
void setThreshholds(uint8_t touch, uint8_t release) __attribute__((deprecated))
DEPRECATED. Use Adafruit_MPR121::setThresholds(uint8_t touch, uint8_t release) instead.
Definition: Adafruit_MPR121.cpp:126
void setThresholds(uint8_t touch, uint8_t release)
Set the touch and release thresholds for all 13 channels on the device to the passed values...
Definition: Adafruit_MPR121.cpp:145
uint16_t touched(void)
Read the touch status of all 13 channels as bit values in a 12 bit integer.
Definition: Adafruit_MPR121.cpp:190
#define MPR121_RELEASE_THRESHOLD_DEFAULT
default relese threshold value
Definition: Adafruit_MPR121.h:32
uint16_t readRegister16(uint8_t reg)
Read the contents of a 16 bit device register.
Definition: Adafruit_MPR121.cpp:211
bool begin(uint8_t i2caddr=MPR121_I2CADDR_DEFAULT, TwoWire *theWire=&Wire, uint8_t touchThreshold=MPR121_TOUCH_THRESHOLD_DEFAULT, uint8_t releaseThreshold=MPR121_RELEASE_THRESHOLD_DEFAULT)
Begin an MPR121 object on a given I2C bus. This function resets the device and writes the default set...
Definition: Adafruit_MPR121.cpp:52
Class that stores state and functions for interacting with MPR121 proximity capacitive touch sensor c...
Definition: Adafruit_MPR121.h:84
uint16_t filteredData(uint8_t t)
Read the filtered data from channel t. The ADC raw data outputs run through 3 levels of digital filte...
Definition: Adafruit_MPR121.cpp:162
#define MPR121_I2CADDR_DEFAULT
default I2C address
Definition: Adafruit_MPR121.h:30
Adafruit_MPR121()
Default constructor.
Definition: Adafruit_MPR121.cpp:37
#define MPR121_TOUCH_THRESHOLD_DEFAULT
default touch threshold value
Definition: Adafruit_MPR121.h:31
uint8_t readRegister8(uint8_t reg)
Read the contents of an 8 bit device register.
Definition: Adafruit_MPR121.cpp:200
void writeRegister(uint8_t reg, uint8_t value)
Writes 8-bits to the specified destination register.
Definition: Adafruit_MPR121.cpp:223