Adafruit MPR121 Library
Public Member Functions | List of all members
Adafruit_MPR121 Class Reference

Class that stores state and functions for interacting with MPR121 proximity capacitive touch sensor controller. More...

#include <Adafruit_MPR121.h>

Public Member Functions

 Adafruit_MPR121 ()
 Default constructor.
 
bool begin (uint8_t i2caddr=MPR121_I2CADDR_DEFAULT, TwoWire *theWire=&Wire, uint8_t touchThreshold=MPR121_TOUCH_THRESHOLD_DEFAULT, uint8_t releaseThreshold=MPR121_RELEASE_THRESHOLD_DEFAULT)
 Begin an MPR121 object on a given I2C bus. This function resets the device and writes the default settings. More...
 
uint16_t filteredData (uint8_t t)
 Read the filtered data from channel t. The ADC raw data outputs run through 3 levels of digital filtering to filter out the high frequency and low frequency noise encountered. For detailed information on this filtering see page 6 of the device datasheet. More...
 
uint16_t baselineData (uint8_t t)
 Read the baseline value for the channel. The 3rd level filtered result is internally 10bit but only high 8 bits are readable from registers 0x1E~0x2A as the baseline value output for each channel. More...
 
uint8_t readRegister8 (uint8_t reg)
 Read the contents of an 8 bit device register. More...
 
uint16_t readRegister16 (uint8_t reg)
 Read the contents of a 16 bit device register. More...
 
void writeRegister (uint8_t reg, uint8_t value)
 Writes 8-bits to the specified destination register. More...
 
uint16_t touched (void)
 Read the touch status of all 13 channels as bit values in a 12 bit integer. More...
 
void setThreshholds (uint8_t touch, uint8_t release) __attribute__((deprecated))
 DEPRECATED. Use Adafruit_MPR121::setThresholds(uint8_t touch, uint8_t release) instead. More...
 
void setThresholds (uint8_t touch, uint8_t release)
 Set the touch and release thresholds for all 13 channels on the device to the passed values. The threshold is defined as a deviation value from the baseline value, so it remains constant even baseline value changes. Typically the touch threshold is a little bigger than the release threshold to touch debounce and hysteresis. For typical touch application, the value can be in range 0x05~0x30 for example. The setting of the threshold is depended on the actual application. For the operation details and how to set the threshold refer to application note AN3892 and MPR121 design guidelines. More...
 

Detailed Description

Class that stores state and functions for interacting with MPR121 proximity capacitive touch sensor controller.

Member Function Documentation

◆ begin()

bool Adafruit_MPR121::begin ( uint8_t  i2caddr = MPR121_I2CADDR_DEFAULT,
TwoWire *  theWire = &Wire,
uint8_t  touchThreshold = MPR121_TOUCH_THRESHOLD_DEFAULT,
uint8_t  releaseThreshold = MPR121_RELEASE_THRESHOLD_DEFAULT 
)

Begin an MPR121 object on a given I2C bus. This function resets the device and writes the default settings.

Parameters
i2caddrthe i2c address the device can be found on. Defaults to 0x5A.
*theWireWire object
touchThresholdtouch detection threshold value
releaseThresholdrelease detection threshold value
Returns
true on success, false otherwise

◆ filteredData()

uint16_t Adafruit_MPR121::filteredData ( uint8_t  t)

Read the filtered data from channel t. The ADC raw data outputs run through 3 levels of digital filtering to filter out the high frequency and low frequency noise encountered. For detailed information on this filtering see page 6 of the device datasheet.

Parameters
tthe channel to read
Returns
the filtered reading as a 10 bit unsigned value

◆ baselineData()

uint16_t Adafruit_MPR121::baselineData ( uint8_t  t)

Read the baseline value for the channel. The 3rd level filtered result is internally 10bit but only high 8 bits are readable from registers 0x1E~0x2A as the baseline value output for each channel.

Parameters
tthe channel to read.
Returns
the baseline data that was read

◆ readRegister8()

uint8_t Adafruit_MPR121::readRegister8 ( uint8_t  reg)

Read the contents of an 8 bit device register.

Parameters
regthe register address to read from
Returns
the 8 bit value that was read.

◆ readRegister16()

uint16_t Adafruit_MPR121::readRegister16 ( uint8_t  reg)

Read the contents of a 16 bit device register.

Parameters
regthe register address to read from
Returns
the 16 bit value that was read.

◆ writeRegister()

void Adafruit_MPR121::writeRegister ( uint8_t  reg,
uint8_t  value 
)

Writes 8-bits to the specified destination register.

Parameters
regthe register address to write to
valuethe value to write

◆ touched()

uint16_t Adafruit_MPR121::touched ( void  )

Read the touch status of all 13 channels as bit values in a 12 bit integer.

Returns
a 12 bit integer with each bit corresponding to the touch status of a sensor. For example, if bit 0 is set then channel 0 of the device is currently deemed to be touched.

◆ setThreshholds()

void Adafruit_MPR121::setThreshholds ( uint8_t  touch,
uint8_t  release 
)

DEPRECATED. Use Adafruit_MPR121::setThresholds(uint8_t touch, uint8_t release) instead.

Parameters
touchsee Adafruit_MPR121::setThresholds(uint8_t touch, uint8_t *release)
releasesee Adafruit_MPR121::setThresholds(uint8_t touch, *uint8_t release)

◆ setThresholds()

void Adafruit_MPR121::setThresholds ( uint8_t  touch,
uint8_t  release 
)

Set the touch and release thresholds for all 13 channels on the device to the passed values. The threshold is defined as a deviation value from the baseline value, so it remains constant even baseline value changes. Typically the touch threshold is a little bigger than the release threshold to touch debounce and hysteresis. For typical touch application, the value can be in range 0x05~0x30 for example. The setting of the threshold is depended on the actual application. For the operation details and how to set the threshold refer to application note AN3892 and MPR121 design guidelines.

Parameters
touchthe touch threshold value from 0 to 255.
releasethe release threshold from 0 to 255.

The documentation for this class was generated from the following files: