Source code for pyupm_mpr121

# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.





from sys import version_info
if version_info >= (2, 6, 0):
    def swig_import_helper():
        from os.path import dirname
        import imp
        fp = None
        try:
            fp, pathname, description = imp.find_module('_pyupm_mpr121', [dirname(__file__)])
        except ImportError:
            import _pyupm_mpr121
            return _pyupm_mpr121
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_mpr121', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_mpr121 = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_mpr121
del version_info
try:
    _swig_property = property
except NameError:
    pass  # Python < 2.2 doesn't have 'property'.


def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
    if (name == "thisown"):
        return self.this.own(value)
    if (name == "this"):
        if type(value).__name__ == 'SwigPyObject':
            self.__dict__[name] = value
            return
    method = class_type.__swig_setmethods__.get(name, None)
    if method:
        return method(self, value)
    if (not static):
        if _newclass:
            object.__setattr__(self, name, value)
        else:
            self.__dict__[name] = value
    else:
        raise AttributeError("You cannot add attributes to %s" % self)


def _swig_setattr(self, class_type, name, value):
    return _swig_setattr_nondynamic(self, class_type, name, value, 0)


def _swig_getattr_nondynamic(self, class_type, name, static=1):
    if (name == "thisown"):
        return self.this.own()
    method = class_type.__swig_getmethods__.get(name, None)
    if method:
        return method(self)
    if (not static):
        return object.__getattr__(self, name)
    else:
        raise AttributeError(name)

def _swig_getattr(self, class_type, name):
    return _swig_getattr_nondynamic(self, class_type, name, 0)


def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except Exception:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)

try:
    _object = object
    _newclass = 1
except AttributeError:
    class _object:
        pass
    _newclass = 0



def getVersion():
    return _pyupm_mpr121.getVersion()
getVersion = _pyupm_mpr121.getVersion

_pyupm_mpr121.MPR121_I2C_BUS_swigconstant(_pyupm_mpr121)
MPR121_I2C_BUS = _pyupm_mpr121.MPR121_I2C_BUS

_pyupm_mpr121.MPR121_DEFAULT_I2C_ADDR_swigconstant(_pyupm_mpr121)
MPR121_DEFAULT_I2C_ADDR = _pyupm_mpr121.MPR121_DEFAULT_I2C_ADDR
[docs]class MPR121(_object): """ API for the MPR121 I2C Touch Sensor. ID: mpr121 Name: Digital Capacitive Touch Sensor Controller Other Names: Grove I2C Touch Sensor Category: touch Manufacturer: seeed Link:http://www.seeedstudio.com/wiki/Grove_-_I2C_Touch_Sensor Connection: i2c Kit: tsk UPM module for the MPR121 touch sensor C++ includes: mpr121.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, MPR121, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, MPR121, name) __repr__ = _swig_repr def __init__(self, bus, address=0x5a): """ MPR121(int bus, uint8_t address=MPR121_DEFAULT_I2C_ADDR) MPR121 constructor Parameters: ----------- bus: I2C bus to use """ this = _pyupm_mpr121.new_MPR121(bus, address) try: self.this.append(this) except Exception: self.this = this
[docs] def configAN3944(self): """ bool configAN3944() MPR121 destructor ~MPR121(); there is no need for the destructor Sets up a default configuration, based on Application Note 3944 (AN3944):http://cache.freescale.com/files/sensors/doc/app_note/AN3944.pdf After configuration, the sensor is left in the run state. True if configuration is successful """ return _pyupm_mpr121.MPR121_configAN3944(self)
[docs] def readButtons(self): """ void readButtons() Reads button states in the m_buttonStates member variable. Also, sets the m_overCurrentFault variable if overcurrent is detected. """ return _pyupm_mpr121.MPR121_readButtons(self)
[docs] def writeBytes(self, reg, buffer, len): """ mraa::Result writeBytes(uint8_t reg, uint8_t *buffer, int len) Writes value(s) into registers Parameters: ----------- reg: Register location to start writing into buffer: Buffer for data storage len: Number of bytes to write mraa::Result """ return _pyupm_mpr121.MPR121_writeBytes(self, reg, buffer, len)
[docs] def readBytes(self, reg, buffer, len): """ int readBytes(uint8_t reg, uint8_t *buffer, int len) Reads value(s) from registers Parameters: ----------- reg: Register location to start reading from buffer: Buffer for data storage len: Number of bytes to read """ return _pyupm_mpr121.MPR121_readBytes(self, reg, buffer, len)
__swig_setmethods__["m_buttonStates"] = _pyupm_mpr121.MPR121_m_buttonStates_set __swig_getmethods__["m_buttonStates"] = _pyupm_mpr121.MPR121_m_buttonStates_get if _newclass: m_buttonStates = _swig_property(_pyupm_mpr121.MPR121_m_buttonStates_get, _pyupm_mpr121.MPR121_m_buttonStates_set) __swig_setmethods__["m_overCurrentFault"] = _pyupm_mpr121.MPR121_m_overCurrentFault_set __swig_getmethods__["m_overCurrentFault"] = _pyupm_mpr121.MPR121_m_overCurrentFault_get if _newclass: m_overCurrentFault = _swig_property(_pyupm_mpr121.MPR121_m_overCurrentFault_get, _pyupm_mpr121.MPR121_m_overCurrentFault_set) __swig_destroy__ = _pyupm_mpr121.delete_MPR121 __del__ = lambda self: None
MPR121_swigregister = _pyupm_mpr121.MPR121_swigregister MPR121_swigregister(MPR121) # This file is compatible with both classic and new-style classes.