use mbed os
Dependents: Seeed_Grove_I2C_Touch_Example
Fork of MPR121 by
Diff: MPR121.cpp
- Revision:
- 1:cee45334b36a
- Parent:
- 0:42add775212a
- Child:
- 2:4c0d4b90a3ed
diff -r 42add775212a -r cee45334b36a MPR121.cpp --- a/MPR121.cpp Thu Mar 07 19:25:08 2013 +0000 +++ b/MPR121.cpp Thu Mar 07 23:57:27 2013 +0000 @@ -109,6 +109,10 @@ { _button = 0; _button_has_changed = 0; + // enable the 12 electrodes - allow disable to put device into + // lower current consumption mode + MPR121::writeRegister(ECR, 0x8f); + // and attach the interrupt handler _irq->fall(this, &MPR121::handler); return; @@ -116,9 +120,14 @@ void MPR121::disable(void) { + // detach the interrupt handler _irq->fall(NULL); _button = 0; _button_has_changed = 0; + // put the device in low current consumption mode - dont re-init registers + MPR121::writeRegister(ECR, 0x0); + MPR121::writeRegister(AUTO_CFG0, 0x0); // REG 0x7B + MPR121::writeRegister(AUTO_CFG1, 0x0); // REG 0x7C return; } @@ -134,7 +143,7 @@ return _button; } -void MPR121::registerDump(void) +void MPR121::registerDump(void) const { uint8_t reg_val = 0; @@ -168,7 +177,7 @@ return; } -void MPR121::writeRegister(uint8_t reg, uint8_t data) +void MPR121::writeRegister(uint8_t const reg, uint8_t const data) const { char buf[2] = {reg, data}; uint8_t result = 0; @@ -185,7 +194,7 @@ return; } -uint8_t MPR121::readRegister(uint8_t reg) +uint8_t MPR121::readRegister(uint8_t const reg) const { uint8_t result = 1, data = 0;