robert@501
|
1 /*
|
robert@501
|
2 * MPR121 Bela demo
|
robert@501
|
3 *
|
robert@501
|
4 * Andrew McPherson
|
robert@501
|
5 * Based on Adafruit library by Limor Fried/Ladyada
|
robert@501
|
6 */
|
robert@501
|
7
|
robert@501
|
8 #ifndef I2CTK_H_
|
robert@501
|
9 #define I2CTK_H_
|
robert@501
|
10
|
robert@501
|
11 #include <I2c.h>
|
robert@501
|
12 #include "Utilities.h"
|
robert@501
|
13
|
robert@501
|
14 typedef bool boolean;
|
robert@501
|
15
|
robert@501
|
16 #define MPR121_I2CADDR_DEFAULT 0x5A
|
robert@501
|
17
|
robert@501
|
18 #define MPR121_TOUCHSTATUS_L 0x00
|
robert@501
|
19 #define MPR121_TOUCHSTATUS_H 0x01
|
robert@501
|
20 #define MPR121_FILTDATA_0L 0x04
|
robert@501
|
21 #define MPR121_FILTDATA_0H 0x05
|
robert@501
|
22 #define MPR121_BASELINE_0 0x1E
|
robert@501
|
23 #define MPR121_MHDR 0x2B
|
robert@501
|
24 #define MPR121_NHDR 0x2C
|
robert@501
|
25 #define MPR121_NCLR 0x2D
|
robert@501
|
26 #define MPR121_FDLR 0x2E
|
robert@501
|
27 #define MPR121_MHDF 0x2F
|
robert@501
|
28 #define MPR121_NHDF 0x30
|
robert@501
|
29 #define MPR121_NCLF 0x31
|
robert@501
|
30 #define MPR121_FDLF 0x32
|
robert@501
|
31 #define MPR121_NHDT 0x33
|
robert@501
|
32 #define MPR121_NCLT 0x34
|
robert@501
|
33 #define MPR121_FDLT 0x35
|
robert@501
|
34
|
robert@501
|
35 #define MPR121_TOUCHTH_0 0x41
|
robert@501
|
36 #define MPR121_RELEASETH_0 0x42
|
robert@501
|
37 #define MPR121_DEBOUNCE 0x5B
|
robert@501
|
38 #define MPR121_CONFIG1 0x5C
|
robert@501
|
39 #define MPR121_CONFIG2 0x5D
|
robert@501
|
40 #define MPR121_CHARGECURR_0 0x5F
|
robert@501
|
41 #define MPR121_CHARGETIME_1 0x6C
|
robert@501
|
42 #define MPR121_ECR 0x5E
|
robert@501
|
43 #define MPR121_AUTOCONFIG0 0x7B
|
robert@501
|
44 #define MPR121_AUTOCONFIG1 0x7C
|
robert@501
|
45 #define MPR121_UPLIMIT 0x7D
|
robert@501
|
46 #define MPR121_LOWLIMIT 0x7E
|
robert@501
|
47 #define MPR121_TARGETLIMIT 0x7F
|
robert@501
|
48
|
robert@501
|
49 #define MPR121_GPIODIR 0x76
|
robert@501
|
50 #define MPR121_GPIOEN 0x77
|
robert@501
|
51 #define MPR121_GPIOSET 0x78
|
robert@501
|
52 #define MPR121_GPIOCLR 0x79
|
robert@501
|
53 #define MPR121_GPIOTOGGLE 0x7A
|
robert@501
|
54
|
robert@501
|
55 #define MPR121_SOFTRESET 0x80
|
robert@501
|
56
|
robert@501
|
57 class I2C_MPR121 : public I2c
|
robert@501
|
58 {
|
robert@501
|
59 public:
|
robert@501
|
60 // Hardware I2C
|
robert@501
|
61 I2C_MPR121();
|
robert@501
|
62
|
robert@501
|
63 boolean begin(uint8_t bus = 1, uint8_t i2caddr = MPR121_I2CADDR_DEFAULT);
|
robert@501
|
64
|
robert@501
|
65 uint16_t filteredData(uint8_t t);
|
robert@501
|
66 uint16_t baselineData(uint8_t t);
|
robert@501
|
67
|
robert@501
|
68 uint8_t readRegister8(uint8_t reg);
|
robert@501
|
69 uint16_t readRegister16(uint8_t reg);
|
robert@501
|
70 void writeRegister(uint8_t reg, uint8_t value);
|
robert@501
|
71 uint16_t touched(void);
|
robert@501
|
72
|
robert@501
|
73 void setThresholds(uint8_t touch, uint8_t release);
|
robert@501
|
74
|
robert@501
|
75 int readI2C() { return 0; } // Unused
|
robert@501
|
76
|
robert@501
|
77 private:
|
robert@501
|
78 int _i2c_address;
|
robert@501
|
79 };
|
robert@501
|
80
|
robert@501
|
81
|
robert@501
|
82 #endif /* I2CTK_H_ */
|