Source code for pyupm_bmpx8x

# 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_bmpx8x', [dirname(__file__)])
        except ImportError:
            import _pyupm_bmpx8x
            return _pyupm_bmpx8x
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_bmpx8x', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_bmpx8x = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_bmpx8x
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_bmpx8x.getVersion()
getVersion = _pyupm_bmpx8x.getVersion
[docs]class IModuleStatus(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, IModuleStatus, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, IModuleStatus, name) def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract") __repr__ = _swig_repr
[docs] def getModuleName(self): """ virtual const char* getModuleName()=0 Returns name of module. This is the string in library name after libupm_ name of module """ return _pyupm_bmpx8x.IModuleStatus_getModuleName(self)
__swig_destroy__ = _pyupm_bmpx8x.delete_IModuleStatus __del__ = lambda self: None
IModuleStatus_swigregister = _pyupm_bmpx8x.IModuleStatus_swigregister IModuleStatus_swigregister(IModuleStatus)
[docs]class ITemperatureSensor(IModuleStatus): """ Interface for Temperature Sensors. C++ includes: iTemperatureSensor.hpp """ __swig_setmethods__ = {} for _s in [IModuleStatus]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, ITemperatureSensor, name, value) __swig_getmethods__ = {} for _s in [IModuleStatus]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, ITemperatureSensor, name) def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract") __repr__ = _swig_repr
[docs] def getTemperatureCelsius(self): """virtual int getTemperatureCelsius()=0 """ return _pyupm_bmpx8x.ITemperatureSensor_getTemperatureCelsius(self)
__swig_destroy__ = _pyupm_bmpx8x.delete_ITemperatureSensor __del__ = lambda self: None
ITemperatureSensor_swigregister = _pyupm_bmpx8x.ITemperatureSensor_swigregister ITemperatureSensor_swigregister(ITemperatureSensor)
[docs]class IPressureSensor(IModuleStatus): __swig_setmethods__ = {} for _s in [IModuleStatus]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, IPressureSensor, name, value) __swig_getmethods__ = {} for _s in [IModuleStatus]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, IPressureSensor, name) def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract") __repr__ = _swig_repr
[docs] def getPressurePa(self): """ virtual int getPressurePa()=0 """ return _pyupm_bmpx8x.IPressureSensor_getPressurePa(self)
__swig_destroy__ = _pyupm_bmpx8x.delete_IPressureSensor __del__ = lambda self: None
IPressureSensor_swigregister = _pyupm_bmpx8x.IPressureSensor_swigregister IPressureSensor_swigregister(IPressureSensor) _pyupm_bmpx8x.BMPX8X_DEFAULT_I2C_BUS_swigconstant(_pyupm_bmpx8x) BMPX8X_DEFAULT_I2C_BUS = _pyupm_bmpx8x.BMPX8X_DEFAULT_I2C_BUS _pyupm_bmpx8x.BMPX8X_DEFAULT_I2C_ADDR_swigconstant(_pyupm_bmpx8x) BMPX8X_DEFAULT_I2C_ADDR = _pyupm_bmpx8x.BMPX8X_DEFAULT_I2C_ADDR _pyupm_bmpx8x.BMPX8X_DEFAULT_CHIPID_swigconstant(_pyupm_bmpx8x) BMPX8X_DEFAULT_CHIPID = _pyupm_bmpx8x.BMPX8X_DEFAULT_CHIPID _pyupm_bmpx8x.BMPX8X_RESET_BYTE_swigconstant(_pyupm_bmpx8x) BMPX8X_RESET_BYTE = _pyupm_bmpx8x.BMPX8X_RESET_BYTE _pyupm_bmpx8x.BMPX8X_CAL_AC1_swigconstant(_pyupm_bmpx8x) BMPX8X_CAL_AC1 = _pyupm_bmpx8x.BMPX8X_CAL_AC1 _pyupm_bmpx8x.BMPX8X_CAL_AC2_swigconstant(_pyupm_bmpx8x) BMPX8X_CAL_AC2 = _pyupm_bmpx8x.BMPX8X_CAL_AC2 _pyupm_bmpx8x.BMPX8X_CAL_AC3_swigconstant(_pyupm_bmpx8x) BMPX8X_CAL_AC3 = _pyupm_bmpx8x.BMPX8X_CAL_AC3 _pyupm_bmpx8x.BMPX8X_CAL_AC4_swigconstant(_pyupm_bmpx8x) BMPX8X_CAL_AC4 = _pyupm_bmpx8x.BMPX8X_CAL_AC4 _pyupm_bmpx8x.BMPX8X_CAL_AC5_swigconstant(_pyupm_bmpx8x) BMPX8X_CAL_AC5 = _pyupm_bmpx8x.BMPX8X_CAL_AC5 _pyupm_bmpx8x.BMPX8X_CAL_AC6_swigconstant(_pyupm_bmpx8x) BMPX8X_CAL_AC6 = _pyupm_bmpx8x.BMPX8X_CAL_AC6 _pyupm_bmpx8x.BMPX8X_CAL_B1_swigconstant(_pyupm_bmpx8x) BMPX8X_CAL_B1 = _pyupm_bmpx8x.BMPX8X_CAL_B1 _pyupm_bmpx8x.BMPX8X_CAL_B2_swigconstant(_pyupm_bmpx8x) BMPX8X_CAL_B2 = _pyupm_bmpx8x.BMPX8X_CAL_B2 _pyupm_bmpx8x.BMPX8X_CAL_MB_swigconstant(_pyupm_bmpx8x) BMPX8X_CAL_MB = _pyupm_bmpx8x.BMPX8X_CAL_MB _pyupm_bmpx8x.BMPX8X_CAL_MC_swigconstant(_pyupm_bmpx8x) BMPX8X_CAL_MC = _pyupm_bmpx8x.BMPX8X_CAL_MC _pyupm_bmpx8x.BMPX8X_CAL_MD_swigconstant(_pyupm_bmpx8x) BMPX8X_CAL_MD = _pyupm_bmpx8x.BMPX8X_CAL_MD _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_swigconstant(_pyupm_bmpx8x) BMPX8X_CTRL_MEAS = _pyupm_bmpx8x.BMPX8X_CTRL_MEAS _pyupm_bmpx8x.BMPX8X_OUTDATA_MSB_swigconstant(_pyupm_bmpx8x) BMPX8X_OUTDATA_MSB = _pyupm_bmpx8x.BMPX8X_OUTDATA_MSB _pyupm_bmpx8x.BMPX8X_OUTDATA_LSB_swigconstant(_pyupm_bmpx8x) BMPX8X_OUTDATA_LSB = _pyupm_bmpx8x.BMPX8X_OUTDATA_LSB _pyupm_bmpx8x.BMPX8X_OUTDATA_XLSB_swigconstant(_pyupm_bmpx8x) BMPX8X_OUTDATA_XLSB = _pyupm_bmpx8x.BMPX8X_OUTDATA_XLSB _pyupm_bmpx8x.BMPX8X_RESET_swigconstant(_pyupm_bmpx8x) BMPX8X_RESET = _pyupm_bmpx8x.BMPX8X_RESET _pyupm_bmpx8x.BMPX8X_CHIP_ID_swigconstant(_pyupm_bmpx8x) BMPX8X_CHIP_ID = _pyupm_bmpx8x.BMPX8X_CHIP_ID _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_CMD0_swigconstant(_pyupm_bmpx8x) BMPX8X_CTRL_MEAS_CMD0 = _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_CMD0 _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_CMD1_swigconstant(_pyupm_bmpx8x) BMPX8X_CTRL_MEAS_CMD1 = _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_CMD1 _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_CMD2_swigconstant(_pyupm_bmpx8x) BMPX8X_CTRL_MEAS_CMD2 = _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_CMD2 _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_CMD3_swigconstant(_pyupm_bmpx8x) BMPX8X_CTRL_MEAS_CMD3 = _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_CMD3 _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_CMD4_swigconstant(_pyupm_bmpx8x) BMPX8X_CTRL_MEAS_CMD4 = _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_CMD4 _pyupm_bmpx8x._BMPX8X_CTRL_MEAS_CMD_MASK_swigconstant(_pyupm_bmpx8x) _BMPX8X_CTRL_MEAS_CMD_MASK = _pyupm_bmpx8x._BMPX8X_CTRL_MEAS_CMD_MASK _pyupm_bmpx8x._BMPX8X_CTRL_MEAS_CMD_SHIFT_swigconstant(_pyupm_bmpx8x) _BMPX8X_CTRL_MEAS_CMD_SHIFT = _pyupm_bmpx8x._BMPX8X_CTRL_MEAS_CMD_SHIFT _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_SCO_swigconstant(_pyupm_bmpx8x) BMPX8X_CTRL_MEAS_SCO = _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_SCO _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_OSS0_swigconstant(_pyupm_bmpx8x) BMPX8X_CTRL_MEAS_OSS0 = _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_OSS0 _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_OSS1_swigconstant(_pyupm_bmpx8x) BMPX8X_CTRL_MEAS_OSS1 = _pyupm_bmpx8x.BMPX8X_CTRL_MEAS_OSS1 _pyupm_bmpx8x._BMPX8X_CTRL_MEAS_OSS_MASK_swigconstant(_pyupm_bmpx8x) _BMPX8X_CTRL_MEAS_OSS_MASK = _pyupm_bmpx8x._BMPX8X_CTRL_MEAS_OSS_MASK _pyupm_bmpx8x._BMPX8X_CTRL_MEAS_OSS_SHIFT_swigconstant(_pyupm_bmpx8x) _BMPX8X_CTRL_MEAS_OSS_SHIFT = _pyupm_bmpx8x._BMPX8X_CTRL_MEAS_OSS_SHIFT _pyupm_bmpx8x.BMPX8X_CMD_READ_TEMP_swigconstant(_pyupm_bmpx8x) BMPX8X_CMD_READ_TEMP = _pyupm_bmpx8x.BMPX8X_CMD_READ_TEMP _pyupm_bmpx8x.BMPX8X_CMD_READ_PRESSURE_swigconstant(_pyupm_bmpx8x) BMPX8X_CMD_READ_PRESSURE = _pyupm_bmpx8x.BMPX8X_CMD_READ_PRESSURE _pyupm_bmpx8x.BMPX8X_OSS_ULTRALOWPOWER_swigconstant(_pyupm_bmpx8x) BMPX8X_OSS_ULTRALOWPOWER = _pyupm_bmpx8x.BMPX8X_OSS_ULTRALOWPOWER _pyupm_bmpx8x.BMPX8X_OSS_STANDARD_swigconstant(_pyupm_bmpx8x) BMPX8X_OSS_STANDARD = _pyupm_bmpx8x.BMPX8X_OSS_STANDARD _pyupm_bmpx8x.BMPX8X_OSS_HIGHRES_swigconstant(_pyupm_bmpx8x) BMPX8X_OSS_HIGHRES = _pyupm_bmpx8x.BMPX8X_OSS_HIGHRES _pyupm_bmpx8x.BMPX8X_OSS_ULTRAHIGHRES_swigconstant(_pyupm_bmpx8x) BMPX8X_OSS_ULTRAHIGHRES = _pyupm_bmpx8x.BMPX8X_OSS_ULTRAHIGHRES
[docs]class BMPX8X(IPressureSensor, ITemperatureSensor): """ API for the GY65/BMP085 and BMP180 Atmospheric Pressure Sensors. ID: bmpx8x Name: BMP Atmospheric Pressure Sensor Other Names: GY65 BMP085 BMP180 BMP183 Category: pressure Manufacturer: bosch seeed adafruit sparkfun Connection: i2c Link:https://www.sparkfun.com/datasheets/Components/General/BST- BMP085-DS000-05.pdf Link:https://www.bosch-sensortec.com/bst/products/all_products/bmp180 Link:https://cdn-shop.adafruit.com/datasheets/1900_BMP183.pdf Bosch GY65/BMP085 and BMP180 are high-precision, ultra-low power consumption pressure sensors. They operate in the range of 30,000-110,000 Pa. This module has been tested on the GY65/BMP085 and BMP180 sensors. C++ includes: bmpx8x.hpp """ __swig_setmethods__ = {} for _s in [IPressureSensor, ITemperatureSensor]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, BMPX8X, name, value) __swig_getmethods__ = {} for _s in [IPressureSensor, ITemperatureSensor]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, BMPX8X, name) __repr__ = _swig_repr def __init__(self, bus=0, addr=0x77): """ BMPX8X(int bus=BMPX8X_DEFAULT_I2C_BUS, int addr=BMPX8X_DEFAULT_I2C_ADDR) Instantiates a BMPX8X object Parameters: ----------- bus: I2C bus to use. addr: The I2C address of the device. Exceptions: ----------- std::runtime_error: on failure. """ this = _pyupm_bmpx8x.new_BMPX8X(bus, addr) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_bmpx8x.delete_BMPX8X __del__ = lambda self: None
[docs] def update(self): """ void update() Query the device and update the internal state. This method must be called before calling getPressure(), getTemperature(), getSealevelPressure(), and getAltitude() to retrieve values. Exceptions: ----------- std::runtime_error: on failure. """ return _pyupm_bmpx8x.BMPX8X_update(self)
[docs] def reset(self): """ void reset() Reset the device to power-on defaults. All calibration data is lost when the device is reset, so you should call init() before attempting to use the device. Exceptions: ----------- std::runtime_error: on failure. """ return _pyupm_bmpx8x.BMPX8X_reset(self)
[docs] def init(self, oss=BMPX8X_OSS_ULTRAHIGHRES): """ void init(BMPX8X_OSS_T oss=BMPX8X_OSS_ULTRAHIGHRES) Initialize the device, read calibration data, and start operation. This function is called from the constructor, so it will not typically need to be called by a user unless the device is reset. Parameters: ----------- oss: One of the BMPX8X_OSS_T values. The default is BMPX8X_OSS_ULTRAHIGHRES. Exceptions: ----------- std::runtime_error: on failure. """ return _pyupm_bmpx8x.BMPX8X_init(self, oss)
[docs] def setOversampling(self, oss=BMPX8X_OSS_ULTRAHIGHRES): """ void setOversampling(BMPX8X_OSS_T oss=BMPX8X_OSS_ULTRAHIGHRES) Set the oversampling (precision mode) of the device. Higher precision requires more time to complete. This call takes effect the next time update() is called. Parameters: ----------- oss: One of the BMPX8X_OSS_T values. The default is BMPX8X_OSS_ULTRAHIGHRES. """ return _pyupm_bmpx8x.BMPX8X_setOversampling(self, oss)
[docs] def getPressure(self): """ int getPressure() Returns the calculated pressure in Pascals. update() must have been called prior to calling this function. The pressure in Pascals. """ return _pyupm_bmpx8x.BMPX8X_getPressure(self)
[docs] def getTemperature(self): """ float getTemperature() Returns the calculated temperature in Celsius. update() must have been called prior to calling this function. The temperature in Celsius. """ return _pyupm_bmpx8x.BMPX8X_getTemperature(self)
[docs] def getSealevelPressure(self, *args): """ int getSealevelPressure() Using the current calculated altitude, compute the pressure at sea level in Pascals. update() must have been called prior to calling this function. The computed sea level pressure in Pascals. """ return _pyupm_bmpx8x.BMPX8X_getSealevelPressure(self, *args)
[docs] def getAltitude(self, sealevelPressure=101325): """ float getAltitude(int sealevelPressure=101325) Calculate the current altitude in meters, given a sea level pressure in Pascals. The default sea level pressure is 101325 Pascals. update() must have been called prior to calling this function. Parameters: ----------- sealevelPressure: The pressure at sea level in Pascals. The default is 101325 Pascals. the computed altitude in meters. """ return _pyupm_bmpx8x.BMPX8X_getAltitude(self, sealevelPressure)
[docs] def getTemperatureCelsius(self): """ int getTemperatureCelsius() Return latest calculated temperature value in Celsius. See ITemperatureSensor. The current temperature in Celsius. """ return _pyupm_bmpx8x.BMPX8X_getTemperatureCelsius(self)
[docs] def getPressurePa(self): """ int getPressurePa() Return latest calculated pressure value in Pascals. See IPressureSensor. The current pressure in Pascals. """ return _pyupm_bmpx8x.BMPX8X_getPressurePa(self)
[docs] def getModuleName(self): """ const char* getModuleName() Returns the name of module. The name of the module. """ return _pyupm_bmpx8x.BMPX8X_getModuleName(self)
BMPX8X_swigregister = _pyupm_bmpx8x.BMPX8X_swigregister BMPX8X_swigregister(BMPX8X) # This file is compatible with both classic and new-style classes.