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