#include <QuickMpr121.h>
Public Member Functions | |
| mpr121 (byte addr=0, TwoWire *wire=&Wire) | |
| Creates an MPR121 device with sane default settings. More... | |
| bool | readTouchState (byte electrode) |
| Reads one touch state bool. More... | |
| short | readTouchState () |
| Reads the 13 touch state bits. More... | |
| short | readOORState () |
| Reads the 15 out of range bits. More... | |
| bool | readOverCurrent () |
| Reads the over current flag. More... | |
| void | clearOverCurrent () |
| Clears the over current flag. More... | |
| short * | readElectrodeData (byte electrode, byte count) |
| Reads filtered analog data for consecutive electrodes. More... | |
| short | readElectrodeData (byte electrode) |
| Reads filtered analog data for a single electrode. More... | |
| byte * | readElectrodeBaseline (byte electrode, byte count) |
| Reads baseline values for consecutive electrodes. More... | |
| byte | readElectrodeBaseline (byte electrode) |
| Reads the baseline value for a single electrode. More... | |
| void | writeElectrodeBaseline (byte electrode, byte count, byte value) |
| Writes a baseline value to consecutive electrodes. More... | |
| void | writeElectrodeBaseline (byte electrode, byte value) |
| Writes the baseline value for a single electrode. More... | |
| void | setAllThresholds (byte touched, byte released, bool prox) |
| A quick way to set all ::touchThresholds and ::releaseThresholds. More... | |
| byte * | readElectrodeCDC (byte electrode, byte count) |
| Reads per-electrode "Charge Discharge Current" (μA) for consecutive electrodes. More... | |
| byte | readElectrodeCDC (byte electrode) |
| Reads per-electrode "Charge Discharge Current" (μA) for a single electrode. More... | |
| void | writeElectrodeCDC (byte electrode, byte count, byte value) |
| Writes per-electrode "Charge Discharge Current" (μA) for consecutive electrodes. More... | |
| void | writeElectrodeCDC (byte electrode, byte value) |
| Writes per-electrode "Charge Discharge Current" (μA) for a single electrode. More... | |
| mpr121FilterCDT * | readElectrodeCDT (byte electrode, byte count) |
| Reads per-electrode "Charge Discharge Time" (μs) for consecutive electrodes. More... | |
| mpr121FilterCDT | readElectrodeCDT (byte electrode) |
| Reads per-electrode "Charge Discharge Time" (μs) for a single electrode. More... | |
| void | writeElectrodeCDT (byte electrode, byte count, mpr121FilterCDT value) |
| Writes per-electrode "Charge Discharge Time" (μs) for consecutive electrodes. More... | |
| void | writeElectrodeCDT (byte electrode, mpr121FilterCDT value) |
| Writes per-electrode "Charge Discharge Time" (μs) for a single electrode. More... | |
| void | setGPIOMode (byte pin, byte count, mpr121GPIOMode mode) |
| Sets pin mode for consecutive GPIO pins. More... | |
| void | setGPIOMode (byte pin, mpr121GPIOMode mode) |
| Sets pin mode for a single GPIO pin. More... | |
| void | writeGPIODigital (byte pin, byte count, bool value) |
| Writes a digital value to consecutive GPIO pins. More... | |
| void | writeGPIODigital (byte pin, bool value) |
| Writes a digital value to a single GPIO pin. More... | |
| void | writeGPIOAnalog (byte pin, byte count, byte value) |
| Writes an "analog" (PWM) value to consecutive GPIO pins. More... | |
| void | writeGPIOAnalog (byte pin, byte value) |
| Writes an "analog" (PWM) value to a single GPIO pin. More... | |
| void | begin (unsigned long clock=400000) |
| Optional alternative to using Wire.begin() and Wire.setClock(). More... | |
| void | start (byte electrodes) |
| Applies settings and enters run mode with a given number of electrodes. More... | |
| void | stop () |
| Exits run mode. More... | |
| bool | checkRunning () |
| Checks if the MPR121 is in run mode. More... | |
| void | softReset () |
| Resets the MPR121. More... | |
Public Attributes | |
| byte | touchThresholds [13] |
| Touch detection thresholds for ELE0-ELE11 and ELEPROX. More... | |
| byte | releaseThresholds [13] |
| Release detection thresholds for ELE0-ELE11 and ELEPROX. More... | |
| byte | MHDrising |
| "Max Half Delta" rising baseline adjustment value (AN3891) – max: 63 More... | |
| byte | MHDfalling |
| "Max Half Delta" falling baseline adjustment value (AN3891) – max: 63 More... | |
| byte | NHDrising |
| "Noise Half Delta" rising baseline adjustment value (AN3891) – max: 63 More... | |
| byte | NHDfalling |
| "Noise Half Delta" falling baseline adjustment value (AN3891) – max: 63 More... | |
| byte | NHDtouched |
| "Noise Half Delta" touched baseline adjustment value (AN3891) – max: 63 More... | |
| byte | NCLrising |
| "Noise Count Limit" rising baseline adjustment value (AN3891) More... | |
| byte | NCLfalling |
| "Noise Count Limit" falling baseline adjustment value (AN3891) More... | |
| byte | NCLtouched |
| "Noise Count Limit" touched baseline adjustment value (AN3891) More... | |
| byte | FDLrising |
| "Filter Delay Limit" rising baseline adjustment value (AN3891) More... | |
| byte | FDLfalling |
| "Filter Delay Limit" falling baseline adjustment value (AN3891) More... | |
| byte | FDLtouched |
| "Filter Delay Limit" touched baseline adjustment value (AN3891) More... | |
| byte | MHDrisingProx |
| "Max Half Delta" rising value for proximity detection (AN3891/AN3893) – max: 63 More... | |
| byte | MHDfallingProx |
| "Max Half Delta" falling value for proximity detection (AN3891/AN3893) – max: 63 More... | |
| byte | NHDrisingProx |
| "Noise Half Delta" rising value for proximity detection (AN3891/AN3893) – max: 63 More... | |
| byte | NHDfallingProx |
| "Noise Half Delta" falling value for proximity detection (AN3891/AN3893) – max: 63 More... | |
| byte | NHDtouchedProx |
| "Noise Half Delta" touched value for proximity detection (AN3891/AN3893) – max: 63 More... | |
| byte | NCLrisingProx |
| "Noise Count Limit" rising value for proximity detection (AN3891/AN3893) More... | |
| byte | NCLfallingProx |
| "Noise Count Limit" falling value for proximity detection (AN3891/AN3893) More... | |
| byte | NCLtouchedProx |
| "Noise Count Limit" touched value for proximity detection (AN3891/AN3893) More... | |
| byte | FDLrisingProx |
| "Filter Delay Limit" rising value for proximity detection (AN3891/AN3893) More... | |
| byte | FDLfallingProx |
| "Filter Delay Limit" falling value for proximity detection (AN3891/AN3893) More... | |
| byte | FDLtouchedProx |
| "Filter Delay Limit" touched value for proximity detection (AN3891/AN3893) More... | |
| byte | debounceTouch |
| Set "Debounce" count for touches (times a detection must be sampled) – max: 7. More... | |
| byte | debounceRelease |
| Set "Debounce" count for releases (times a detection must be sampled) – max: 7. More... | |
| mpr121FilterFFI | FFI |
| "First Filter Iterations" (number of samples taken for the first level of filtering) More... | |
| byte | globalCDC |
| Global "Charge Discharge Current" (μA), not used if autoconfig is enabled – max 63. More... | |
| mpr121FilterCDT | globalCDT |
| Global "Charge Discharge Time" (μs), not used if autoconfig is enabled. More... | |
| mpr121FilterSFI | SFI |
| "Second Filter Iterations" (number of samples taken for the second level of filtering) More... | |
| mpr121FilterESI | ESI |
| "Electrode Sample Interval" (ms) More... | |
| mpr121ElectrodeConfigCL | calLock |
| "Calibration Lock" (baseline tracking and initial value settings) More... | |
| mpr121ElectrodeConfigProx | proxEnable |
| ELEPROX_EN: sets what electrodes will be used for proximity detection. More... | |
| byte | autoConfigUSL |
| "Up-Side Limit" for auto calibration – if not set when starting, this will be automatically set to the ideal value for 1.8V supply More... | |
| byte | autoConfigLSL |
| "Low-Side Limit" for auto calibration – if not set when starting, this will be automatically set based on USL More... | |
| byte | autoConfigTL |
| "Target Level" for auto calibration – if not set when starting, this will be automatically set based on USL More... | |
| mpr121AutoConfigRetry | autoConfigRetry |
| Number of retries for failed auto-config before out of range will be set. More... | |
| mpr121AutoConfigBVA | autoConfigBaselineAdjust |
| "Baseline Value Adjust" changes how the baseline registers will be set after auto-configuration completes More... | |
| bool | autoConfigEnableReconfig |
| "Automatic Reconfiguration Enable" will try to reconfigure out of range (failed) channels every sampling interval More... | |
| bool | autoConfigEnableCalibration |
| "Automatic Configuration Enable" will enable/disable auto-configuration when entering run mode More... | |
| bool | autoConfigSkipChargeTime |
| "Skip Charge Time Search" will skip searching for charge time and use the already-set per-electrode or global value More... | |
| bool | autoConfigInterruptOOR |
| "Out-of-range interrupt enable" will trigger an interrupt when a channel is determined to be out of range More... | |
| bool | autoConfigInterruptARF |
| "Auto-reconfiguration fail interrupt enable" will trigger an interrupt when auto-reconfiguration fails More... | |
| bool | autoConfigInterruptACF |
| "Auto-configuration fail interrupt enable" will trigger an interrupt when auto-configuration fails More... | |
| mpr121::mpr121 | ( | byte | addr = 0, |
| TwoWire * | wire = &Wire |
||
| ) |
Creates an MPR121 device with sane default settings.
| addr | The I2C address to use. If not specified (or ==0), the next valid address will be chosen automatically. |
| wire | You can pass in an alternative TwoWire instance. |
Definition at line 308 of file QuickMpr121.cpp.
| void mpr121::begin | ( | unsigned long | clock = 400000 | ) |
Optional alternative to using Wire.begin() and Wire.setClock().
Also has a built-in delay to ensure MPR121s are ready.
Definition at line 767 of file QuickMpr121.cpp.
| bool mpr121::checkRunning | ( | ) |
Checks if the MPR121 is in run mode.
Definition at line 842 of file QuickMpr121.cpp.
| void mpr121::clearOverCurrent | ( | ) |
Clears the over current flag.
(over current on REXT pin, probably shouldn't happen in normal operation)
Definition at line 529 of file QuickMpr121.cpp.
|
inline |
Reads the baseline value for a single electrode.
Definition at line 445 of file QuickMpr121.h.
| byte * mpr121::readElectrodeBaseline | ( | byte | electrode, |
| byte | count | ||
| ) |
Reads baseline values for consecutive electrodes.
Definition at line 549 of file QuickMpr121.cpp.
|
inline |
Reads per-electrode "Charge Discharge Current" (μA) for a single electrode.
Definition at line 477 of file QuickMpr121.h.
| byte * mpr121::readElectrodeCDC | ( | byte | electrode, |
| byte | count | ||
| ) |
Reads per-electrode "Charge Discharge Current" (μA) for consecutive electrodes.
Definition at line 588 of file QuickMpr121.cpp.
|
inline |
Reads per-electrode "Charge Discharge Time" (μs) for a single electrode.
Definition at line 503 of file QuickMpr121.h.
| mpr121FilterCDT * mpr121::readElectrodeCDT | ( | byte | electrode, |
| byte | count | ||
| ) |
Reads per-electrode "Charge Discharge Time" (μs) for consecutive electrodes.
Definition at line 613 of file QuickMpr121.cpp.
|
inline |
Reads filtered analog data for a single electrode.
Definition at line 433 of file QuickMpr121.h.
| short * mpr121::readElectrodeData | ( | byte | electrode, |
| byte | count | ||
| ) |
Reads filtered analog data for consecutive electrodes.
Definition at line 535 of file QuickMpr121.cpp.
| short mpr121::readOORState | ( | ) |
Reads the 15 out of range bits.
[13]: auto-config fail flag [14]: auto-reconfig fail flag
Definition at line 461 of file QuickMpr121.cpp.
| bool mpr121::readOverCurrent | ( | ) |
Reads the over current flag.
(over current on REXT pin, probably shouldn't happen in normal operation)
Definition at line 523 of file QuickMpr121.cpp.
| short mpr121::readTouchState | ( | ) |
Reads the 13 touch state bits.
Also use this for reading GPIO inputs.
Definition at line 453 of file QuickMpr121.cpp.
| bool mpr121::readTouchState | ( | byte | electrode | ) |
Reads one touch state bool.
Also use this for reading GPIO inputs.
When multiple touches must be read, using the variant that returns data for all 13 is preferred. This does implement a simple cache though, so performance shouldn't be drastically different.
Definition at line 426 of file QuickMpr121.cpp.
| void mpr121::setAllThresholds | ( | byte | touched, |
| byte | released, | ||
| bool | prox | ||
| ) |
A quick way to set all ::touchThresholds and ::releaseThresholds.
| prox | Whether to set proximity detection thresholds too. |
Definition at line 574 of file QuickMpr121.cpp.
| void mpr121::setGPIOMode | ( | byte | pin, |
| byte | count, | ||
| mpr121GPIOMode | mode | ||
| ) |
Sets pin mode for consecutive GPIO pins.
GPIO can be used on pins 4-11 when they aren't used for sensing. Use mode MPR_GPIO_MODE_OUTPUT_OPENDRAIN_HIGH for direct LED driving – it can source up to 12mA.
Definition at line 662 of file QuickMpr121.cpp.
|
inline |
Sets pin mode for a single GPIO pin.
GPIO can be used on pins 4-11 when they aren't used for sensing. Use mode MPR_GPIO_MODE_OUTPUT_OPENDRAIN_HIGH for direct LED driving – it can source up to 12mA.
Definition at line 534 of file QuickMpr121.h.
| void mpr121::softReset | ( | ) |
Resets the MPR121.
Definition at line 848 of file QuickMpr121.cpp.
| void mpr121::start | ( | byte | electrodes | ) |
Applies settings and enters run mode with a given number of electrodes.
Very much based on the quick start guide (AN3944).
Definition at line 779 of file QuickMpr121.cpp.
| void mpr121::stop | ( | ) |
Exits run mode.
Definition at line 835 of file QuickMpr121.cpp.
| void mpr121::writeElectrodeBaseline | ( | byte | electrode, |
| byte | count, | ||
| byte | value | ||
| ) |
Writes a baseline value to consecutive electrodes.
Definition at line 563 of file QuickMpr121.cpp.
|
inline |
Writes the baseline value for a single electrode.
Definition at line 457 of file QuickMpr121.h.
| void mpr121::writeElectrodeCDC | ( | byte | electrode, |
| byte | count, | ||
| byte | value | ||
| ) |
Writes per-electrode "Charge Discharge Current" (μA) for consecutive electrodes.
Max: 63
Definition at line 603 of file QuickMpr121.cpp.
|
inline |
Writes per-electrode "Charge Discharge Current" (μA) for a single electrode.
Max: 63
Definition at line 491 of file QuickMpr121.h.
| void mpr121::writeElectrodeCDT | ( | byte | electrode, |
| byte | count, | ||
| mpr121FilterCDT | value | ||
| ) |
Writes per-electrode "Charge Discharge Time" (μs) for consecutive electrodes.
Definition at line 633 of file QuickMpr121.cpp.
|
inline |
Writes per-electrode "Charge Discharge Time" (μs) for a single electrode.
Definition at line 515 of file QuickMpr121.h.
| void mpr121::writeGPIOAnalog | ( | byte | pin, |
| byte | count, | ||
| byte | value | ||
| ) |
Writes an "analog" (PWM) value to consecutive GPIO pins.
Max value is 15
Pin 9 apparently has a logic bug and pin 10 must also have its data set high for it to work. (see https://community.nxp.com/thread/305474)
Definition at line 744 of file QuickMpr121.cpp.
|
inline |
Writes an "analog" (PWM) value to a single GPIO pin.
Max value is 15
Pin 9 apparently has a logic bug and pin 10 must also have its data set high for it to work. (see https://community.nxp.com/thread/305474)
Definition at line 566 of file QuickMpr121.h.
|
inline |
Writes a digital value to a single GPIO pin.
Definition at line 546 of file QuickMpr121.h.
| void mpr121::writeGPIODigital | ( | byte | pin, |
| byte | count, | ||
| bool | value | ||
| ) |
Writes a digital value to consecutive GPIO pins.
Definition at line 719 of file QuickMpr121.cpp.
| mpr121AutoConfigBVA mpr121::autoConfigBaselineAdjust |
"Baseline Value Adjust" changes how the baseline registers will be set after auto-configuration completes
Definition at line 366 of file QuickMpr121.h.
| bool mpr121::autoConfigEnableCalibration |
"Automatic Configuration Enable" will enable/disable auto-configuration when entering run mode
Definition at line 368 of file QuickMpr121.h.
| bool mpr121::autoConfigEnableReconfig |
"Automatic Reconfiguration Enable" will try to reconfigure out of range (failed) channels every sampling interval
Definition at line 367 of file QuickMpr121.h.
| bool mpr121::autoConfigInterruptACF |
"Auto-configuration fail interrupt enable" will trigger an interrupt when auto-configuration fails
Definition at line 375 of file QuickMpr121.h.
| bool mpr121::autoConfigInterruptARF |
"Auto-reconfiguration fail interrupt enable" will trigger an interrupt when auto-reconfiguration fails
Definition at line 374 of file QuickMpr121.h.
| bool mpr121::autoConfigInterruptOOR |
"Out-of-range interrupt enable" will trigger an interrupt when a channel is determined to be out of range
Definition at line 373 of file QuickMpr121.h.
| byte mpr121::autoConfigLSL |
"Low-Side Limit" for auto calibration – if not set when starting, this will be automatically set based on USL
Definition at line 363 of file QuickMpr121.h.
| mpr121AutoConfigRetry mpr121::autoConfigRetry |
Number of retries for failed auto-config before out of range will be set.
Definition at line 365 of file QuickMpr121.h.
| bool mpr121::autoConfigSkipChargeTime |
"Skip Charge Time Search" will skip searching for charge time and use the already-set per-electrode or global value
This results in a shorter time to configure, but the designer must supply appropriate values.
Definition at line 370 of file QuickMpr121.h.
| byte mpr121::autoConfigTL |
"Target Level" for auto calibration – if not set when starting, this will be automatically set based on USL
Definition at line 364 of file QuickMpr121.h.
| byte mpr121::autoConfigUSL |
"Up-Side Limit" for auto calibration – if not set when starting, this will be automatically set to the ideal value for 1.8V supply
Definition at line 362 of file QuickMpr121.h.
| mpr121ElectrodeConfigCL mpr121::calLock |
"Calibration Lock" (baseline tracking and initial value settings)
Definition at line 359 of file QuickMpr121.h.
| byte mpr121::debounceRelease |
Set "Debounce" count for releases (times a detection must be sampled) – max: 7.
Definition at line 349 of file QuickMpr121.h.
| byte mpr121::debounceTouch |
Set "Debounce" count for touches (times a detection must be sampled) – max: 7.
Definition at line 348 of file QuickMpr121.h.
| mpr121FilterESI mpr121::ESI |
"Electrode Sample Interval" (ms)
Definition at line 356 of file QuickMpr121.h.
| byte mpr121::FDLfalling |
"Filter Delay Limit" falling baseline adjustment value (AN3891)
Definition at line 328 of file QuickMpr121.h.
| byte mpr121::FDLfallingProx |
"Filter Delay Limit" falling value for proximity detection (AN3891/AN3893)
Definition at line 344 of file QuickMpr121.h.
| byte mpr121::FDLrising |
"Filter Delay Limit" rising baseline adjustment value (AN3891)
Definition at line 327 of file QuickMpr121.h.
| byte mpr121::FDLrisingProx |
"Filter Delay Limit" rising value for proximity detection (AN3891/AN3893)
Definition at line 343 of file QuickMpr121.h.
| byte mpr121::FDLtouched |
"Filter Delay Limit" touched baseline adjustment value (AN3891)
Definition at line 329 of file QuickMpr121.h.
| byte mpr121::FDLtouchedProx |
"Filter Delay Limit" touched value for proximity detection (AN3891/AN3893)
Definition at line 345 of file QuickMpr121.h.
| mpr121FilterFFI mpr121::FFI |
"First Filter Iterations" (number of samples taken for the first level of filtering)
Definition at line 352 of file QuickMpr121.h.
| byte mpr121::globalCDC |
Global "Charge Discharge Current" (μA), not used if autoconfig is enabled – max 63.
Definition at line 353 of file QuickMpr121.h.
| mpr121FilterCDT mpr121::globalCDT |
Global "Charge Discharge Time" (μs), not used if autoconfig is enabled.
Definition at line 354 of file QuickMpr121.h.
| byte mpr121::MHDfalling |
"Max Half Delta" falling baseline adjustment value (AN3891) – max: 63
Definition at line 317 of file QuickMpr121.h.
| byte mpr121::MHDfallingProx |
"Max Half Delta" falling value for proximity detection (AN3891/AN3893) – max: 63
Definition at line 333 of file QuickMpr121.h.
| byte mpr121::MHDrising |
"Max Half Delta" rising baseline adjustment value (AN3891) – max: 63
Definition at line 316 of file QuickMpr121.h.
| byte mpr121::MHDrisingProx |
"Max Half Delta" rising value for proximity detection (AN3891/AN3893) – max: 63
Definition at line 332 of file QuickMpr121.h.
| byte mpr121::NCLfalling |
"Noise Count Limit" falling baseline adjustment value (AN3891)
Definition at line 324 of file QuickMpr121.h.
| byte mpr121::NCLfallingProx |
"Noise Count Limit" falling value for proximity detection (AN3891/AN3893)
Definition at line 340 of file QuickMpr121.h.
| byte mpr121::NCLrising |
"Noise Count Limit" rising baseline adjustment value (AN3891)
Definition at line 323 of file QuickMpr121.h.
| byte mpr121::NCLrisingProx |
"Noise Count Limit" rising value for proximity detection (AN3891/AN3893)
Definition at line 339 of file QuickMpr121.h.
| byte mpr121::NCLtouched |
"Noise Count Limit" touched baseline adjustment value (AN3891)
Definition at line 325 of file QuickMpr121.h.
| byte mpr121::NCLtouchedProx |
"Noise Count Limit" touched value for proximity detection (AN3891/AN3893)
Definition at line 341 of file QuickMpr121.h.
| byte mpr121::NHDfalling |
"Noise Half Delta" falling baseline adjustment value (AN3891) – max: 63
Definition at line 320 of file QuickMpr121.h.
| byte mpr121::NHDfallingProx |
"Noise Half Delta" falling value for proximity detection (AN3891/AN3893) – max: 63
Definition at line 336 of file QuickMpr121.h.
| byte mpr121::NHDrising |
"Noise Half Delta" rising baseline adjustment value (AN3891) – max: 63
Definition at line 319 of file QuickMpr121.h.
| byte mpr121::NHDrisingProx |
"Noise Half Delta" rising value for proximity detection (AN3891/AN3893) – max: 63
Definition at line 335 of file QuickMpr121.h.
| byte mpr121::NHDtouched |
"Noise Half Delta" touched baseline adjustment value (AN3891) – max: 63
Definition at line 321 of file QuickMpr121.h.
| byte mpr121::NHDtouchedProx |
"Noise Half Delta" touched value for proximity detection (AN3891/AN3893) – max: 63
Definition at line 337 of file QuickMpr121.h.
| mpr121ElectrodeConfigProx mpr121::proxEnable |
ELEPROX_EN: sets what electrodes will be used for proximity detection.
Definition at line 360 of file QuickMpr121.h.
| byte mpr121::releaseThresholds[13] |
Release detection thresholds for ELE0-ELE11 and ELEPROX.
Definition at line 314 of file QuickMpr121.h.
| mpr121FilterSFI mpr121::SFI |
"Second Filter Iterations" (number of samples taken for the second level of filtering)
Definition at line 355 of file QuickMpr121.h.
| byte mpr121::touchThresholds[13] |
Touch detection thresholds for ELE0-ELE11 and ELEPROX.
Definition at line 313 of file QuickMpr121.h.