robert@501: /* robert@501: * MPR121 Bela demo robert@501: * robert@501: * Andrew McPherson robert@501: * Based on Adafruit library by Limor Fried/Ladyada robert@501: */ robert@501: robert@501: #ifndef I2CTK_H_ robert@501: #define I2CTK_H_ robert@501: robert@501: #include robert@501: #include "Utilities.h" robert@501: robert@501: typedef bool boolean; robert@501: robert@501: #define MPR121_I2CADDR_DEFAULT 0x5A robert@501: robert@501: #define MPR121_TOUCHSTATUS_L 0x00 robert@501: #define MPR121_TOUCHSTATUS_H 0x01 robert@501: #define MPR121_FILTDATA_0L 0x04 robert@501: #define MPR121_FILTDATA_0H 0x05 robert@501: #define MPR121_BASELINE_0 0x1E robert@501: #define MPR121_MHDR 0x2B robert@501: #define MPR121_NHDR 0x2C robert@501: #define MPR121_NCLR 0x2D robert@501: #define MPR121_FDLR 0x2E robert@501: #define MPR121_MHDF 0x2F robert@501: #define MPR121_NHDF 0x30 robert@501: #define MPR121_NCLF 0x31 robert@501: #define MPR121_FDLF 0x32 robert@501: #define MPR121_NHDT 0x33 robert@501: #define MPR121_NCLT 0x34 robert@501: #define MPR121_FDLT 0x35 robert@501: robert@501: #define MPR121_TOUCHTH_0 0x41 robert@501: #define MPR121_RELEASETH_0 0x42 robert@501: #define MPR121_DEBOUNCE 0x5B robert@501: #define MPR121_CONFIG1 0x5C robert@501: #define MPR121_CONFIG2 0x5D robert@501: #define MPR121_CHARGECURR_0 0x5F robert@501: #define MPR121_CHARGETIME_1 0x6C robert@501: #define MPR121_ECR 0x5E robert@501: #define MPR121_AUTOCONFIG0 0x7B robert@501: #define MPR121_AUTOCONFIG1 0x7C robert@501: #define MPR121_UPLIMIT 0x7D robert@501: #define MPR121_LOWLIMIT 0x7E robert@501: #define MPR121_TARGETLIMIT 0x7F robert@501: robert@501: #define MPR121_GPIODIR 0x76 robert@501: #define MPR121_GPIOEN 0x77 robert@501: #define MPR121_GPIOSET 0x78 robert@501: #define MPR121_GPIOCLR 0x79 robert@501: #define MPR121_GPIOTOGGLE 0x7A robert@501: robert@501: #define MPR121_SOFTRESET 0x80 robert@501: robert@501: class I2C_MPR121 : public I2c robert@501: { robert@501: public: robert@501: // Hardware I2C robert@501: I2C_MPR121(); robert@501: robert@501: boolean begin(uint8_t bus = 1, uint8_t i2caddr = MPR121_I2CADDR_DEFAULT); robert@501: robert@501: uint16_t filteredData(uint8_t t); robert@501: uint16_t baselineData(uint8_t t); robert@501: robert@501: uint8_t readRegister8(uint8_t reg); robert@501: uint16_t readRegister16(uint8_t reg); robert@501: void writeRegister(uint8_t reg, uint8_t value); robert@501: uint16_t touched(void); robert@501: robert@501: void setThresholds(uint8_t touch, uint8_t release); robert@501: robert@501: int readI2C() { return 0; } // Unused robert@501: robert@501: private: robert@501: int _i2c_address; robert@501: }; robert@501: robert@501: robert@501: #endif /* I2CTK_H_ */