mpr121_bool

MPR121 Capacitive Touch Sensor (I2C). Tested with: https://www.adafruit.com/product/1982 The touch output is the 0/1 status of the touch plates (bits 0..11) Note: This object requires a single instance of the factory/gpio/i2c/config object. This allows multiple mpr121 devices (each with a unique i2c address) to work concurrently. Tested with I2C1, SCL=PB8, SDA=PB9 (these are the config defaults)
Author: Jason Harris
License: BSD
Github: deadsy/mpr121/mpr121_bool.axo

Inlets

None

Outlets

bool32 o0

bool32 o1

bool32 o2

bool32 o3

bool32 o4

bool32 o5

bool32 o6

bool32 o7

bool32 o8

bool32 o9

bool32 o10

bool32 o11

Attributes

combo adr

Declaration
// Register values are tuned for electrode geometry.
// Here are some reasonable defaults, but you may need
// to tune these values for your specific application.
// See: https://www.nxp.com/docs/en/data-sheet/MPR121.pdf

const struct mpr121_cfg config[34] = {
    {MPR121_TOUCH_THRESHOLD(0), 6},
    {MPR121_TOUCH_THRESHOLD(1), 6},
    {MPR121_TOUCH_THRESHOLD(2), 6},
    {MPR121_TOUCH_THRESHOLD(3), 6},
    {MPR121_TOUCH_THRESHOLD(4), 6},
    {MPR121_TOUCH_THRESHOLD(5), 6},
    {MPR121_TOUCH_THRESHOLD(6), 6},
    {MPR121_TOUCH_THRESHOLD(7), 6},
    {MPR121_TOUCH_THRESHOLD(8), 6},
    {MPR121_TOUCH_THRESHOLD(9), 6},
    {MPR121_TOUCH_THRESHOLD(10), 6},
    {MPR121_TOUCH_THRESHOLD(11), 6},

    {MPR121_RELEASE_THRESHOLD(0), 12},
    {MPR121_RELEASE_THRESHOLD(1), 12},
    {MPR121_RELEASE_THRESHOLD(2), 12},
    {MPR121_RELEASE_THRESHOLD(3), 12},
    {MPR121_RELEASE_THRESHOLD(4), 12},
    {MPR121_RELEASE_THRESHOLD(5), 12},
    {MPR121_RELEASE_THRESHOLD(6), 12},
    {MPR121_RELEASE_THRESHOLD(7), 12},
    {MPR121_RELEASE_THRESHOLD(8), 12},
    {MPR121_RELEASE_THRESHOLD(9), 12},
    {MPR121_RELEASE_THRESHOLD(10), 12},
    {MPR121_RELEASE_THRESHOLD(11), 12},

    {MPR121_MHD_RISING, 0x01},
    {MPR121_NHD_RISING, 0x01},
    {MPR121_NCL_RISING, 0x0E},
    {MPR121_MHD_FALLING, 0x01},
    {MPR121_NHD_FALLING, 0x05},
    {MPR121_NCL_FALLING, 0x01},
    {MPR121_CDC_CONFIG, 0x10}, // default, 16uA charge current
    {MPR121_CDT_CONFIG, 0x20}, // 0.5uS encoding, 1ms period
    {MPR121_ELECTRODE_CONFIG,
     0x8F},   // start with first 5 bits of baseline tracking
    {0xff, 0} // end-of-list
};

struct mpr121_state state;
Init
mpr121_init(&state, &config[0], attr_adr);
Control Rate
mpr121_krate_bool(&state, &outlet_o0, &outlet_o1, &outlet_o2, &outlet_o3,
                  &outlet_o4, &outlet_o5, &outlet_o6, &outlet_o7, &outlet_o8,
                  &outlet_o9, &outlet_o10, &outlet_o11);
Dispose
mpr121_dispose(&state);

Privacy

© 2024 Zrna Research