# 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_mpl3115a2', [dirname(__file__)])
except ImportError:
import _pyupm_mpl3115a2
return _pyupm_mpl3115a2
if fp is not None:
try:
_mod = imp.load_module('_pyupm_mpl3115a2', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_mpl3115a2 = swig_import_helper()
del swig_import_helper
else:
import _pyupm_mpl3115a2
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_mpl3115a2.getVersion()
getVersion = _pyupm_mpl3115a2.getVersion
_pyupm_mpl3115a2.MPL3115A2_NAME_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_NAME = _pyupm_mpl3115a2.MPL3115A2_NAME
_pyupm_mpl3115a2.MPL3115A2_I2C_ADDRESS_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_I2C_ADDRESS = _pyupm_mpl3115a2.MPL3115A2_I2C_ADDRESS
_pyupm_mpl3115a2.MPL3115A2_DEVICE_ID_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_DEVICE_ID = _pyupm_mpl3115a2.MPL3115A2_DEVICE_ID
_pyupm_mpl3115a2.MPL3115A2_STATUS_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_STATUS = _pyupm_mpl3115a2.MPL3115A2_STATUS
_pyupm_mpl3115a2.MPL3115A2_OUT_PRESS_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_OUT_PRESS = _pyupm_mpl3115a2.MPL3115A2_OUT_PRESS
_pyupm_mpl3115a2.MPL3115A2_OUT_TEMP_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_OUT_TEMP = _pyupm_mpl3115a2.MPL3115A2_OUT_TEMP
_pyupm_mpl3115a2.MPL3115A2_WHO_AM_I_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_WHO_AM_I = _pyupm_mpl3115a2.MPL3115A2_WHO_AM_I
_pyupm_mpl3115a2.MPL3115A2_PT_DATA_CFG_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_PT_DATA_CFG = _pyupm_mpl3115a2.MPL3115A2_PT_DATA_CFG
_pyupm_mpl3115a2.MPL3115A2_P_MIN_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_P_MIN = _pyupm_mpl3115a2.MPL3115A2_P_MIN
_pyupm_mpl3115a2.MPL3115A2_T_MIN_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_T_MIN = _pyupm_mpl3115a2.MPL3115A2_T_MIN
_pyupm_mpl3115a2.MPL3115A2_P_MAX_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_P_MAX = _pyupm_mpl3115a2.MPL3115A2_P_MAX
_pyupm_mpl3115a2.MPL3115A2_T_MAX_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_T_MAX = _pyupm_mpl3115a2.MPL3115A2_T_MAX
_pyupm_mpl3115a2.MPL3115A2_CTRL_REG1_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_CTRL_REG1 = _pyupm_mpl3115a2.MPL3115A2_CTRL_REG1
_pyupm_mpl3115a2.MPL3115A2_CTRL_SBYB_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_CTRL_SBYB = _pyupm_mpl3115a2.MPL3115A2_CTRL_SBYB
_pyupm_mpl3115a2.MPL3115A2_CTRL_OST_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_CTRL_OST = _pyupm_mpl3115a2.MPL3115A2_CTRL_OST
_pyupm_mpl3115a2.MPL3115A2_CTRL_RESET_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_CTRL_RESET = _pyupm_mpl3115a2.MPL3115A2_CTRL_RESET
_pyupm_mpl3115a2.MPL3115A2_CTRL_ALT_MODE_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_CTRL_ALT_MODE = _pyupm_mpl3115a2.MPL3115A2_CTRL_ALT_MODE
_pyupm_mpl3115a2.MPL3115A2_MAXOVERSAMPLE_swigconstant(_pyupm_mpl3115a2)
MPL3115A2_MAXOVERSAMPLE = _pyupm_mpl3115a2.MPL3115A2_MAXOVERSAMPLE
[docs]class MPL3115A2(_object):
"""
API for the MPL3115A2 Atmospheric Pressure Sensor.
ID: mpl3115a2
Name: I2C Precision Altimeter
Category: pressure
Manufacturer: freescale
Link:http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MPL3115A2
Connection: i2c Freescale Semiconductor*MPL3115A2 is a high-
precision, ultra-low power consumption pressure sensor. Its operating
range is 50-110 kPa.
C++ includes: mpl3115a2.hpp
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, MPL3115A2, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, MPL3115A2, name)
__repr__ = _swig_repr
def __init__(self, bus, devAddr=0x60, mode=6):
"""
MPL3115A2(int bus,
int devAddr=MPL3115A2_I2C_ADDRESS, uint8_t mode=6)
Instantiates an MPL3115A2 object
Parameters:
-----------
bus: Number of the used bus
devAddr: Address of the used I2C device
mode: MPL3115A2 oversampling (6 = 64x)
"""
this = _pyupm_mpl3115a2.new_MPL3115A2(bus, devAddr, mode)
try:
self.this.append(this)
except Exception:
self.this = this
[docs] def testSensor(self):
"""
int
testSensor(void)
MPL3115A2 object destructor; basically, it closes the I2C connection.
~MPL3115A2(); no need for this here, as the I2c connection will be
closed when the m_i2ControlCtx variable will go out of scope Tests the
sensor and tries to determine if the sensor is operating by looking
for small variations in the value
"""
return _pyupm_mpl3115a2.MPL3115A2_testSensor(self)
[docs] def resetSensor(self):
"""
int
resetSensor(void)
Performs a soft reset of the MPL3115A2 device to ensure it is in a
known state. This function can be used to reset the min/max
temperature and pressure values.
"""
return _pyupm_mpl3115a2.MPL3115A2_resetSensor(self)
[docs] def dumpSensor(self):
"""
void
dumpSensor(void)
Dumps out the I2C register block to stdout
"""
return _pyupm_mpl3115a2.MPL3115A2_dumpSensor(self)
[docs] def sampleData(self):
"""
int
sampleData(void)
Initiates a temperature/pressure mesasurement and waits for the
function to complete. Temperature and pressure registers can be read
after this call.
"""
return _pyupm_mpl3115a2.MPL3115A2_sampleData(self)
[docs] def getPressureReg(self, reg):
"""
int32_t
getPressureReg(int reg)
Reads the pressure value from MPL3115A2 [Pa * 100]
Parameters:
-----------
reg: Base address of the pressure register
"""
return _pyupm_mpl3115a2.MPL3115A2_getPressureReg(self, reg)
[docs] def getTempReg(self, reg):
"""
int32_t
getTempReg(int reg)
Reads the temperature value from MPL3115A2 [degC * 1000]
Parameters:
-----------
reg: Base address of the temperature register
"""
return _pyupm_mpl3115a2.MPL3115A2_getTempReg(self, reg)
[docs] def getPressure(self, bSampleData=True):
"""
float
getPressure(int bSampleData=true)
Reads the current pressure value from MPL3115A2 [Pa]
Parameters:
-----------
bSampleData: Sets non-zero to a sample reading
"""
return _pyupm_mpl3115a2.MPL3115A2_getPressure(self, bSampleData)
[docs] def getTemperature(self, bSampleData=True):
"""
float
getTemperature(int bSampleData=true)
Reads the current temperature value from MPL3115A2 [degC]
Parameters:
-----------
bSampleData: Sets non-zero to a sample reading
"""
return _pyupm_mpl3115a2.MPL3115A2_getTemperature(self, bSampleData)
[docs] def getSealevelPressure(self, altitudeMeters=0.0):
"""
float
getSealevelPressure(float altitudeMeters=0.0)
Reads the current pressure and, using a known altitude, calculates the
sea level pressure value [Pa] This function should be preceded by the
sampleData() call
Parameters:
-----------
altitudeMeters: Altitude in meters
"""
return _pyupm_mpl3115a2.MPL3115A2_getSealevelPressure(self, altitudeMeters)
[docs] def getAltitude(self, sealevelPressure=101325.0):
"""
float
getAltitude(float sealevelPressure=101325.0)
Reads the current pressure and, using a known sea level pressure,
calculates the altitude value [m] This function should be preceded by
the sampleData() call
Parameters:
-----------
sealevelPressure: Current sea level pressure
"""
return _pyupm_mpl3115a2.MPL3115A2_getAltitude(self, sealevelPressure)
[docs] def setOversampling(self, oversampling):
"""
void
setOversampling(uint8_t oversampling)
Defines the oversampling setting (ranges from 0 to 7). The value
represents 2^n samples (ranging from 1 to 128). The time to calculate
a sample is approximately (2^n * 4 + 2) ms
Parameters:
-----------
oversampling: New oversampling value
"""
return _pyupm_mpl3115a2.MPL3115A2_setOversampling(self, oversampling)
[docs] def getOversampling(self):
"""
uint8_t
getOversampling(void)
Returns the current oversampling value
"""
return _pyupm_mpl3115a2.MPL3115A2_getOversampling(self)
[docs] def getTemperatureMax(self):
"""
float
getTemperatureMax(void)
Reads the maximum measured temperature [degC]
"""
return _pyupm_mpl3115a2.MPL3115A2_getTemperatureMax(self)
[docs] def getTemperatureMin(self):
"""
float
getTemperatureMin(void)
Reads the minimum measured temperature [degC]
"""
return _pyupm_mpl3115a2.MPL3115A2_getTemperatureMin(self)
[docs] def getPressureMax(self):
"""
float
getPressureMax(void)
Reads the maximum measured pressure [Pa]
"""
return _pyupm_mpl3115a2.MPL3115A2_getPressureMax(self)
[docs] def getPressureMin(self):
"""
float
getPressureMin(void)
Reads the minimum measured pressure [Pa]
"""
return _pyupm_mpl3115a2.MPL3115A2_getPressureMin(self)
[docs] def convertTempCtoF(self, fTemp):
"""
float
convertTempCtoF(float fTemp)
Converts temperature from degC*1000 to degF*1000
Parameters:
-----------
fTemp: Temperature in degC
"""
return _pyupm_mpl3115a2.MPL3115A2_convertTempCtoF(self, fTemp)
[docs] def convertPaToinHg(self, fPressure):
"""
float
convertPaToinHg(float fPressure)
Converts pressure from Pa*100 to inHg*10000 This is set for 15degC (Pa
= 0.0002961 in Hg) TODO: Change the function to add temperature
calibration
Parameters:
-----------
fPressure: Pressure in Pa
"""
return _pyupm_mpl3115a2.MPL3115A2_convertPaToinHg(self, fPressure)
[docs] def i2cWriteReg(self, reg, value):
"""
mraa::Result
i2cWriteReg(uint8_t reg, uint8_t value)
Writes one byte to an I2C register
Parameters:
-----------
reg: Address of the register
value: Byte to be written
"""
return _pyupm_mpl3115a2.MPL3115A2_i2cWriteReg(self, reg, value)
[docs] def i2cReadReg_16(self, reg):
"""
uint16_t
i2cReadReg_16(int reg)
Reads two bytes from an I2C register
Parameters:
-----------
reg: Address of the register
"""
return _pyupm_mpl3115a2.MPL3115A2_i2cReadReg_16(self, reg)
[docs] def i2cReadReg_8(self, reg):
"""
uint8_t
i2cReadReg_8(int reg)
Reads a one-byte register
Parameters:
-----------
reg: Address of the register
"""
return _pyupm_mpl3115a2.MPL3115A2_i2cReadReg_8(self, reg)
__swig_destroy__ = _pyupm_mpl3115a2.delete_MPL3115A2
__del__ = lambda self: None
MPL3115A2_swigregister = _pyupm_mpl3115a2.MPL3115A2_swigregister
MPL3115A2_swigregister(MPL3115A2)
# This file is compatible with both classic and new-style classes.