Class daisy::Mpr121¶
Device support for MPR121 12x Capacitive Touch Sensor. More...
#include <mpr121.h>
Classes¶
Type | Name |
---|---|
struct | Config |
Public Types¶
Type | Name |
---|---|
enum | RegMap |
enum | Result |
Public Functions¶
Type | Name |
---|---|
uint16_t | BaselineData (uint8_t t) |
uint16_t | FilteredData (uint8_t t) |
Result | Init (Config config) |
Mpr121 () |
|
uint16_t | ReadRegister16 (uint8_t reg) |
uint8_t | ReadRegister8 (uint8_t reg) |
void | SetThresholds (uint8_t touch, uint8_t release) |
uint16_t | Touched () |
void | WriteRegister (uint8_t reg, uint8_t value) |
~Mpr121 () |
Detailed Description¶
Author:
beserge
Date:
December 2021
Public Types Documentation¶
enum RegMap¶
enum daisy::Mpr121::RegMap {
MPR121_TOUCHSTATUS_L = 0x00,
MPR121_TOUCHSTATUS_H = 0x01,
MPR121_FILTDATA_0L = 0x04,
MPR121_FILTDATA_0H = 0x05,
MPR121_BASELINE_0 = 0x1E,
MPR121_MHDR = 0x2B,
MPR121_NHDR = 0x2C,
MPR121_NCLR = 0x2D,
MPR121_FDLR = 0x2E,
MPR121_MHDF = 0x2F,
MPR121_NHDF = 0x30,
MPR121_NCLF = 0x31,
MPR121_FDLF = 0x32,
MPR121_NHDT = 0x33,
MPR121_NCLT = 0x34,
MPR121_FDLT = 0x35,
MPR121_TOUCHTH_0 = 0x41,
MPR121_RELEASETH_0 = 0x42,
MPR121_DEBOUNCE = 0x5B,
MPR121_CONFIG1 = 0x5C,
MPR121_CONFIG2 = 0x5D,
MPR121_CHARGECURR_0 = 0x5F,
MPR121_CHARGETIME_1 = 0x6C,
MPR121_ECR = 0x5E,
MPR121_AUTOCONFIG0 = 0x7B,
MPR121_AUTOCONFIG1 = 0x7C,
MPR121_UPLIMIT = 0x7D,
MPR121_LOWLIMIT = 0x7E,
MPR121_TARGETLIMIT = 0x7F,
MPR121_GPIODIR = 0x76,
MPR121_GPIOEN = 0x77,
MPR121_GPIOSET = 0x78,
MPR121_GPIOCLR = 0x79,
MPR121_GPIOTOGGLE = 0x7A,
MPR121_SOFTRESET = 0x80
};
Device register map
enum Result¶
Public Functions Documentation¶
function BaselineData¶
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:
t
the channel to read.
Returns:
the baseline data that was read
function FilteredData¶
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:
t
the channel to read
Returns:
the filtered reading as a 10 bit unsigned value
function Init¶
Initialize the MPR121 device
Parameters:
config
Configuration settings
function Mpr121¶
function ReadRegister16¶
Read the contents of a 16 bit device register.
Parameters:
reg
the register address to read from
Returns:
the 16 bit value that was read.
function ReadRegister8¶
Read the contents of an 8 bit device register.
Parameters:
reg
the register address to read from
Returns:
the 8 bit value that was read.
function SetThresholds¶
Set the touch and release thresholds for all 13 channels on the device to the passed values.
Parameters:
touch
The touch threshold value from 0 to 255.release
The release threshold from 0 to 255.
function Touched¶
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.
function WriteRegister¶
Writes 8-bits to the specified destination register
Parameters:
reg
the register address to write tovalue
the value to write
function ~Mpr121¶
The documentation for this class was generated from the following file external-docs/libDaisy/src/dev/mpr121.h