use mbed os
Dependents: Seeed_Grove_I2C_Touch_Example
Fork of MPR121 by
MPR121 Class Reference
Using the Sparkfun SEN-10250 BoB. More...
#include <MPR121.h>
Public Member Functions | |
MPR121 (I2C &i2c) | |
Create the MPR121 object. | |
bool | isPressed (void) |
Determine if a new button press event occured Upon calling the state is cleared until another press is detected. | |
uint16_t | buttonPressed (void) |
Get the electrode status (ELE12 ... |
Detailed Description
Using the Sparkfun SEN-10250 BoB.
Example:
#include "mbed.h" #include "MPR121.h" Serial pc(USBTX, USBRX); DigitalOut myled(LED1); #if defined TARGET_LPC1768 || TARGET_LPC11U24 I2C i2c(p28, p27); InterruptIn irq(p26); MPR121 touch_pad(i2c, irq, MPR121::ADDR_VSS); #elif defined TARGET_KL25Z I2C i2c(PTC9, PTC8); InterruptIn irq(PTA5); MPR121 touch_pad(i2c, irq, MPR121::ADDR_VSS); #else #error TARGET NOT TESTED #endif int main() { touch_pad.init(); touch_pad.enable(); while(1) { if(touch_pad.isPressed()) { uint16_t button_val = touch_pad.buttonPressed(); printf("button = 0x%04x\n", button_val); myled = (button_val>0) ? 1 : 0; } } }
API for the MPR121 capacitive touch IC
Definition at line 76 of file MPR121.h.
Constructor & Destructor Documentation
MPR121 | ( | I2C & | i2c ) |
Create the MPR121 object.
- Parameters:
-
i2c - A defined I2C object i2c_addr - Connection of the address line
Definition at line 28 of file MPR121.cpp.
Member Function Documentation
uint16_t buttonPressed | ( | void | ) |
Get the electrode status (ELE12 ...
ELE0 -> b15 xxx b11 ... b0 The buttons are bit mapped. ELE0 = b0 ... ELE11 = b11 b12 ... b15 undefined
- Returns:
- The state of all buttons
Definition at line 39 of file MPR121.cpp.
bool isPressed | ( | void | ) |
Determine if a new button press event occured Upon calling the state is cleared until another press is detected.
- Returns:
- 1 if a press has been detected since the last call, 0 otherwise
Definition at line 34 of file MPR121.cpp.
Generated on Thu Jul 21 2022 09:50:13 by 1.7.2