Source code for pyupm_bmi160

# 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_bmi160', [dirname(__file__)])
        except ImportError:
            import _pyupm_bmi160
            return _pyupm_bmi160
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_bmi160', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_bmi160 = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_bmi160
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_bmi160.getVersion()
getVersion = _pyupm_bmi160.getVersion

def new_floatp():
    return _pyupm_bmi160.new_floatp()
new_floatp = _pyupm_bmi160.new_floatp

def copy_floatp(value):
    return _pyupm_bmi160.copy_floatp(value)
copy_floatp = _pyupm_bmi160.copy_floatp

def delete_floatp(obj):
    return _pyupm_bmi160.delete_floatp(obj)
delete_floatp = _pyupm_bmi160.delete_floatp

def floatp_assign(obj, value):
    return _pyupm_bmi160.floatp_assign(obj, value)
floatp_assign = _pyupm_bmi160.floatp_assign

def floatp_value(obj):
    return _pyupm_bmi160.floatp_value(obj)
floatp_value = _pyupm_bmi160.floatp_value

_pyupm_bmi160.BMI160_CHIP_ID_swigconstant(_pyupm_bmi160)
BMI160_CHIP_ID = _pyupm_bmi160.BMI160_CHIP_ID

_pyupm_bmi160.BMI160_ACC_RANGE_2G_swigconstant(_pyupm_bmi160)
BMI160_ACC_RANGE_2G = _pyupm_bmi160.BMI160_ACC_RANGE_2G

_pyupm_bmi160.BMI160_ACC_RANGE_4G_swigconstant(_pyupm_bmi160)
BMI160_ACC_RANGE_4G = _pyupm_bmi160.BMI160_ACC_RANGE_4G

_pyupm_bmi160.BMI160_ACC_RANGE_8G_swigconstant(_pyupm_bmi160)
BMI160_ACC_RANGE_8G = _pyupm_bmi160.BMI160_ACC_RANGE_8G

_pyupm_bmi160.BMI160_ACC_RANGE_16G_swigconstant(_pyupm_bmi160)
BMI160_ACC_RANGE_16G = _pyupm_bmi160.BMI160_ACC_RANGE_16G

_pyupm_bmi160.BMI160_GYRO_RANGE_125_swigconstant(_pyupm_bmi160)
BMI160_GYRO_RANGE_125 = _pyupm_bmi160.BMI160_GYRO_RANGE_125

_pyupm_bmi160.BMI160_GYRO_RANGE_250_swigconstant(_pyupm_bmi160)
BMI160_GYRO_RANGE_250 = _pyupm_bmi160.BMI160_GYRO_RANGE_250

_pyupm_bmi160.BMI160_GYRO_RANGE_500_swigconstant(_pyupm_bmi160)
BMI160_GYRO_RANGE_500 = _pyupm_bmi160.BMI160_GYRO_RANGE_500

_pyupm_bmi160.BMI160_GYRO_RANGE_1000_swigconstant(_pyupm_bmi160)
BMI160_GYRO_RANGE_1000 = _pyupm_bmi160.BMI160_GYRO_RANGE_1000

_pyupm_bmi160.BMI160_GYRO_RANGE_2000_swigconstant(_pyupm_bmi160)
BMI160_GYRO_RANGE_2000 = _pyupm_bmi160.BMI160_GYRO_RANGE_2000

_pyupm_bmi160.BMI160_I2C_BUS_swigconstant(_pyupm_bmi160)
BMI160_I2C_BUS = _pyupm_bmi160.BMI160_I2C_BUS

_pyupm_bmi160.BMI160_DEFAULT_I2C_ADDR_swigconstant(_pyupm_bmi160)
BMI160_DEFAULT_I2C_ADDR = _pyupm_bmi160.BMI160_DEFAULT_I2C_ADDR
[docs]class BMI160(_object): """ UPM API for the BMI160 3-axis Accelerometer, Gyroscope and Magnetometer. ID: bmi160 Name: Low-power IMU (triaxial Accelerometer and Triaxial Gyroscope) and Magnetometer Category: accelerometer compass Manufacturer: bosch mouser Connection: i2c Link:https://www.bosch-sensortec.com/bst/products/all_products/bmi160 The Bosch BMI160 is a 3-axis Accelerometer and Gyroscope. Additionally it supports an external Magnetometer, accessed through the BMI160's register interface. This driver was developed with a BMI160 "Shuttle" board, which included a BMM150 Magnetometer. The device is driven by either 1.8v or 3.3vdc. This driver incorporates the Bosch BMI160 driver code athttps://github.com/BoschSensortec/BMI160_driver The Bosch driver code does not provide a mechanism for passing user data around (like the device context). For this reason, only one instance of this driver can be used in a given process, due to the use of static data in the driver. While not all of the functionality of this device is supported initially, the inclusion of the Bosch driver in the source code makes it possible to support whatever features are required that the driver can support. C++ includes: bmi160.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, BMI160, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, BMI160, name) __repr__ = _swig_repr def __init__(self, bus=0, address=0x69, csPin=-1, enableMag=True): """ BMI160(int bus=BMI160_I2C_BUS, int address=BMI160_DEFAULT_I2C_ADDR, int csPin=-1, bool enableMag=true) BMI160 constructor. The default arguments inititialize I2C operation and the default I2C address. Parameters: ----------- bus: i2c bus to use address: The address for this device if using I2C. If using SPI, supply -1 for this parameter. csPin: The GPIO to use for Chip Select (CS). This is only needed for SPI, and only if your SPI implementation requires it. Otherwise, just pass -1 if not using SPI, or your CS is handled automatically by your SPI implementation. enableMag: true to enable the magnetometer, false otherwise """ this = _pyupm_bmi160.new_BMI160(bus, address, csPin, enableMag) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_bmi160.delete_BMI160 __del__ = lambda self: None
[docs] def update(self): """ void update() Take a measurement and store the current sensor values internally. This function must be called prior to retrieving any sensor values, for example getAccelerometer(). """ return _pyupm_bmi160.BMI160_update(self)
[docs] def setAccelerometerScale(self, scale): """ void setAccelerometerScale(BMI160_ACC_RANGE_T scale) set the scaling mode of the accelerometer Parameters: ----------- scale: one of the ACCEL_RANGE_T values """ return _pyupm_bmi160.BMI160_setAccelerometerScale(self, scale)
[docs] def setGyroscopeScale(self, scale): """ void setGyroscopeScale(BMI160_GYRO_RANGE_T scale) set the scaling mode of the gyroscope Parameters: ----------- scale: one of the GYRO_RANGE_T values """ return _pyupm_bmi160.BMI160_setGyroscopeScale(self, scale)
[docs] def getAccelerometer(self, *args): """ void getAccelerometer(float *x, float *y, float *z) Get the Accelerometer values. The values returned are in gravities. update() must have been called prior to calling this method. Parameters: ----------- x: A pointer into which the X value will be returned y: A pointer into which the Y value will be returned z: A pointer into which the Z value will be returned """ return _pyupm_bmi160.BMI160_getAccelerometer(self, *args)
[docs] def getGyroscope(self, *args): """ void getGyroscope(float *x, float *y, float *z) Get the Gyroscope values. The values returned are in degrees per second. update() must have been called prior to calling this method. Parameters: ----------- x: A pointer into which the X value will be returned y: A pointer into which the Y value will be returned z: A pointer into which the Z value will be returned """ return _pyupm_bmi160.BMI160_getGyroscope(self, *args)
[docs] def getMagnetometer(self, *args): """ void getMagnetometer(float *x, float *y, float *z) Get the Magnetometer values. The values returned are in micro Teslas. update() must have been called prior to calling this method. Parameters: ----------- x: A pointer into which the X value will be returned y: A pointer into which the Y value will be returned z: A pointer into which the Z value will be returned """ return _pyupm_bmi160.BMI160_getMagnetometer(self, *args)
[docs] def enableMagnetometer(self, enable): """ void enableMagnetometer(bool enable) Enable or disable the Magnetometer. By default, the magnetometer is enabled. Parameters: ----------- enable: true to enable the magnetometer, false to disable. """ return _pyupm_bmi160.BMI160_enableMagnetometer(self, enable)
[docs] def getSensorTime(self): """ unsigned int getSensorTime() Return the sensor time. This is a 24bit value that increments every 39us. It will wrap around once the 24b resolution is exceeded. The current sensor time. """ return _pyupm_bmi160.BMI160_getSensorTime(self)
BMI160_swigregister = _pyupm_bmi160.BMI160_swigregister BMI160_swigregister(BMI160) # This file is compatible with both classic and new-style classes.