Source code for pyupm_lsm303dlh

# 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_lsm303dlh', [dirname(__file__)])
        except ImportError:
            import _pyupm_lsm303dlh
            return _pyupm_lsm303dlh
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_lsm303dlh', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_lsm303dlh = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_lsm303dlh
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_lsm303dlh.getVersion()
getVersion = _pyupm_lsm303dlh.getVersion
[docs]class int16Array(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, int16Array, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, int16Array, name) __repr__ = _swig_repr def __init__(self, nelements): this = _pyupm_lsm303dlh.new_int16Array(nelements) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_lsm303dlh.delete_int16Array __del__ = lambda self: None def __getitem__(self, index): return _pyupm_lsm303dlh.int16Array___getitem__(self, index) def __setitem__(self, index, value): return _pyupm_lsm303dlh.int16Array___setitem__(self, index, value)
[docs] def cast(self): return _pyupm_lsm303dlh.int16Array_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _pyupm_lsm303dlh.int16Array_frompointer if _newclass: frompointer = staticmethod(_pyupm_lsm303dlh.int16Array_frompointer)
int16Array_swigregister = _pyupm_lsm303dlh.int16Array_swigregister int16Array_swigregister(int16Array) def int16Array_frompointer(t): return _pyupm_lsm303dlh.int16Array_frompointer(t) int16Array_frompointer = _pyupm_lsm303dlh.int16Array_frompointer _pyupm_lsm303dlh.LSM303DLH_MAG_swigconstant(_pyupm_lsm303dlh) LSM303DLH_MAG = _pyupm_lsm303dlh.LSM303DLH_MAG _pyupm_lsm303dlh.LSM303DLH_ACC_swigconstant(_pyupm_lsm303dlh) LSM303DLH_ACC = _pyupm_lsm303dlh.LSM303DLH_ACC _pyupm_lsm303dlh.CTRL_REG1_A_swigconstant(_pyupm_lsm303dlh) CTRL_REG1_A = _pyupm_lsm303dlh.CTRL_REG1_A _pyupm_lsm303dlh.CTRL_REG2_A_swigconstant(_pyupm_lsm303dlh) CTRL_REG2_A = _pyupm_lsm303dlh.CTRL_REG2_A _pyupm_lsm303dlh.CTRL_REG3_A_swigconstant(_pyupm_lsm303dlh) CTRL_REG3_A = _pyupm_lsm303dlh.CTRL_REG3_A _pyupm_lsm303dlh.CTRL_REG4_A_swigconstant(_pyupm_lsm303dlh) CTRL_REG4_A = _pyupm_lsm303dlh.CTRL_REG4_A _pyupm_lsm303dlh.CTRL_REG5_A_swigconstant(_pyupm_lsm303dlh) CTRL_REG5_A = _pyupm_lsm303dlh.CTRL_REG5_A _pyupm_lsm303dlh.CRA_REG_M_swigconstant(_pyupm_lsm303dlh) CRA_REG_M = _pyupm_lsm303dlh.CRA_REG_M _pyupm_lsm303dlh.CRB_REG_M_swigconstant(_pyupm_lsm303dlh) CRB_REG_M = _pyupm_lsm303dlh.CRB_REG_M _pyupm_lsm303dlh.MR_REG_M_swigconstant(_pyupm_lsm303dlh) MR_REG_M = _pyupm_lsm303dlh.MR_REG_M _pyupm_lsm303dlh.OUT_X_H_M_swigconstant(_pyupm_lsm303dlh) OUT_X_H_M = _pyupm_lsm303dlh.OUT_X_H_M _pyupm_lsm303dlh.OUT_X_L_A_swigconstant(_pyupm_lsm303dlh) OUT_X_L_A = _pyupm_lsm303dlh.OUT_X_L_A _pyupm_lsm303dlh.OUT_X_H_A_swigconstant(_pyupm_lsm303dlh) OUT_X_H_A = _pyupm_lsm303dlh.OUT_X_H_A _pyupm_lsm303dlh.OUT_Y_L_A_swigconstant(_pyupm_lsm303dlh) OUT_Y_L_A = _pyupm_lsm303dlh.OUT_Y_L_A _pyupm_lsm303dlh.OUT_Y_H_A_swigconstant(_pyupm_lsm303dlh) OUT_Y_H_A = _pyupm_lsm303dlh.OUT_Y_H_A _pyupm_lsm303dlh.OUT_Z_L_A_swigconstant(_pyupm_lsm303dlh) OUT_Z_L_A = _pyupm_lsm303dlh.OUT_Z_L_A _pyupm_lsm303dlh.OUT_Z_H_A_swigconstant(_pyupm_lsm303dlh) OUT_Z_H_A = _pyupm_lsm303dlh.OUT_Z_H_A _pyupm_lsm303dlh.X_swigconstant(_pyupm_lsm303dlh) X = _pyupm_lsm303dlh.X _pyupm_lsm303dlh.Y_swigconstant(_pyupm_lsm303dlh) Y = _pyupm_lsm303dlh.Y _pyupm_lsm303dlh.Z_swigconstant(_pyupm_lsm303dlh) Z = _pyupm_lsm303dlh.Z
[docs]class LSM303DLH(_object): """ API for the LSM303DLH Accelerometer & Compass. ID: lsm303dlh Name: Triaxial Accelerometer/magnetometer Other Names: Grove 6-Axis Accelerometer & Compass Category: accelerometer compass Manufacturer: seeed adafruit stmicro Link:http://www.seeedstudio.com/wiki/Grove_-_6-Axis_Accelerometer%26Compass Connection: i2c This module defines the LSM303DLHDLH 3-axis magnetometer/3-axis accelerometer. This module was tested with the Seeed Studio* Grove 6-Axis Accelerometer & Compass module used over I2C. The magnetometer and acceleromter are accessed at two seperate I2C addresses. C++ includes: lsm303dlh.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, LSM303DLH, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, LSM303DLH, name) __repr__ = _swig_repr LSM303DLH_MAG_T = _pyupm_lsm303dlh.LSM303DLH_LSM303DLH_MAG_T LSM303DLH_ACC_T = _pyupm_lsm303dlh.LSM303DLH_LSM303DLH_ACC_T def __init__(self, bus, addrMag=0x1E, addrAcc=0x19, accScale=8): """ LSM303DLH(int bus, int addrMag=LSM303DLH_MAG, int addrAcc=LSM303DLH_ACC, int accScale=8) Instantiates an LSM303DLH object Parameters: ----------- bus: I2C bus to use addrMag: I2C address of the Magnetometer (default 0x1E) addrAcc: I2C address of the Accelerometer (default 0x19) accScale: Accelerometer scale, can be 2, 4 or 8 (default 8) """ this = _pyupm_lsm303dlh.new_LSM303DLH(bus, addrMag, addrAcc, accScale) try: self.this.append(this) except Exception: self.this = this
[docs] def getHeading(self): """ float getHeading() LSM303DLH object destructor where is no more need for this here - I2c connection will be stopped automatically when m_i2c variable will go out of scope ~LSM303DLH (); Gets the current heading; headings <0 indicate an error has occurred float """ return _pyupm_lsm303dlh.LSM303DLH_getHeading(self)
[docs] def getCoordinates(self): """ mraa::Result getCoordinates() Gets the coordinates in the XYZ order """ return _pyupm_lsm303dlh.LSM303DLH_getCoordinates(self)
[docs] def getAcceleration(self): """ mraa::Result getAcceleration() Gets accelerometer values Should be called before other "get" functions for acceleration """ return _pyupm_lsm303dlh.LSM303DLH_getAcceleration(self)
[docs] def getRawCoorData(self): """ int16_t * getRawCoorData() Gets raw coordinate data; it is updated when getCoordinates() is called """ return _pyupm_lsm303dlh.LSM303DLH_getRawCoorData(self)
[docs] def getCoorX(self): """ int16_t getCoorX() Gets the X component of the coordinates data """ return _pyupm_lsm303dlh.LSM303DLH_getCoorX(self)
[docs] def getCoorY(self): """ int16_t getCoorY() Gets the Y component of the coordinates data """ return _pyupm_lsm303dlh.LSM303DLH_getCoorY(self)
[docs] def getCoorZ(self): """ int16_t getCoorZ() Gets the Z component of the coordinates data """ return _pyupm_lsm303dlh.LSM303DLH_getCoorZ(self)
[docs] def getRawAccelData(self): """ int16_t * getRawAccelData() Gets raw accelerometer data; it is updated when getAcceleration() is called """ return _pyupm_lsm303dlh.LSM303DLH_getRawAccelData(self)
[docs] def getAccelX(self): """ int16_t getAccelX() Gets the X component of the acceleration data """ return _pyupm_lsm303dlh.LSM303DLH_getAccelX(self)
[docs] def getAccelY(self): """ int16_t getAccelY() Gets the Y component of the acceleration data """ return _pyupm_lsm303dlh.LSM303DLH_getAccelY(self)
[docs] def getAccelZ(self): """ int16_t getAccelZ() Gets the Z component of the acceleration data """ return _pyupm_lsm303dlh.LSM303DLH_getAccelZ(self)
__swig_destroy__ = _pyupm_lsm303dlh.delete_LSM303DLH __del__ = lambda self: None
LSM303DLH_swigregister = _pyupm_lsm303dlh.LSM303DLH_swigregister LSM303DLH_swigregister(LSM303DLH) # This file is compatible with both classic and new-style classes.