Source code for pyupm_mcp9808

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

_pyupm_mcp9808.MCP9808_REG_CONFIG_swigconstant(_pyupm_mcp9808)
MCP9808_REG_CONFIG = _pyupm_mcp9808.MCP9808_REG_CONFIG

_pyupm_mcp9808.MCP9808_REG_AMBIENT_TEMP_swigconstant(_pyupm_mcp9808)
MCP9808_REG_AMBIENT_TEMP = _pyupm_mcp9808.MCP9808_REG_AMBIENT_TEMP

_pyupm_mcp9808.MCP9808_REG_MANUF_ID_swigconstant(_pyupm_mcp9808)
MCP9808_REG_MANUF_ID = _pyupm_mcp9808.MCP9808_REG_MANUF_ID

_pyupm_mcp9808.MCP9808_REG_DEVICE_ID_swigconstant(_pyupm_mcp9808)
MCP9808_REG_DEVICE_ID = _pyupm_mcp9808.MCP9808_REG_DEVICE_ID

_pyupm_mcp9808.MCP9808_REG_RESOLUTION_swigconstant(_pyupm_mcp9808)
MCP9808_REG_RESOLUTION = _pyupm_mcp9808.MCP9808_REG_RESOLUTION

_pyupm_mcp9808.MCP9808_CONFIG_SHUTDOWN_swigconstant(_pyupm_mcp9808)
MCP9808_CONFIG_SHUTDOWN = _pyupm_mcp9808.MCP9808_CONFIG_SHUTDOWN

_pyupm_mcp9808.MCP9808_CONFIG_CRITLOCKED_swigconstant(_pyupm_mcp9808)
MCP9808_CONFIG_CRITLOCKED = _pyupm_mcp9808.MCP9808_CONFIG_CRITLOCKED

_pyupm_mcp9808.MCP9808_CONFIG_WINLOCKED_swigconstant(_pyupm_mcp9808)
MCP9808_CONFIG_WINLOCKED = _pyupm_mcp9808.MCP9808_CONFIG_WINLOCKED

_pyupm_mcp9808.MCP9808_CONFIG_INTCLR_swigconstant(_pyupm_mcp9808)
MCP9808_CONFIG_INTCLR = _pyupm_mcp9808.MCP9808_CONFIG_INTCLR
[docs]class MCP9808(_object): """ API for MCP9808 precision temprature sensor. ID: MCP9808 Name: High Accuracy I2C Temperature Sensor Category: temp Manufacturer: adafruit Connection: i2c Link:https://learn.adafruit.com/adafruit-mcp9808-precision-i2c- temperature- sensor-guide/overview Link:http://ww1.microchip.com/downloads/en/DeviceDoc/25095A.pdf The MCP9808 digital temperature sensor converts temperatures between -20 deg C and +100 deg C to a digital word with +/- 0.5 deg C (max.) accuracy. The MCP9808 comes with user-programmable registers that provide flexibility for temperature sensing applications. The registers allow user-selectable settings such as Shutdown or low-power modes and the specification of temperature Event and Critical output boundaries. When the temperature changes beyond the specified boundary limits, the MCP9808 outputs an Event signal. The user has the option of setting the event output signal polarity as an active-low or active-high comparator output for thermostat operation, or as temperature event interrupt output for microprocessor-based systems. The event output can also be configured as a Critical temperature output. Tested with Adafriut MCP9808 board. C++ includes: mcp9808.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, MCP9808, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, MCP9808, name) __repr__ = _swig_repr UPPER_TEMP = _pyupm_mcp9808.MCP9808_UPPER_TEMP LOWER_TEMP = _pyupm_mcp9808.MCP9808_LOWER_TEMP CRIT_TEMP = _pyupm_mcp9808.MCP9808_CRIT_TEMP RES_LOW = _pyupm_mcp9808.MCP9808_RES_LOW RES_MEDIUM = _pyupm_mcp9808.MCP9808_RES_MEDIUM RES_HIGH = _pyupm_mcp9808.MCP9808_RES_HIGH RES_PRECISION = _pyupm_mcp9808.MCP9808_RES_PRECISION ALERTSTAT = _pyupm_mcp9808.MCP9808_ALERTSTAT ALERTCTRL = _pyupm_mcp9808.MCP9808_ALERTCTRL ALERTSEL = _pyupm_mcp9808.MCP9808_ALERTSEL ALERTPOL = _pyupm_mcp9808.MCP9808_ALERTPOL ALERTMODE = _pyupm_mcp9808.MCP9808_ALERTMODE HYST_0 = _pyupm_mcp9808.MCP9808_HYST_0 HYST_1_5 = _pyupm_mcp9808.MCP9808_HYST_1_5 HYST_3_0 = _pyupm_mcp9808.MCP9808_HYST_3_0 HYST_6_0 = _pyupm_mcp9808.MCP9808_HYST_6_0 def __init__(self, bus, address=0x18): """ MCP9808(int bus, uint8_t address=0x18) MCP9808 constructor Parameters: ----------- bus: i2c bus the sensor is attached to. address: Device address. Default is 0x18. """ this = _pyupm_mcp9808.new_MCP9808(bus, address) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_mcp9808.delete_MCP9808 __del__ = lambda self: None
[docs] def name(self): """ std::string name() Returns the name of the sensor """ return _pyupm_mcp9808.MCP9808_name(self)
[docs] def getTemp(self): """ float getTemp(void) Returns current temperature. """ return _pyupm_mcp9808.MCP9808_getTemp(self)
[docs] def shutDown(self, sleep=True): """ void shutDown(bool sleep=true) Will cause the devices to either sleep or wakeup. Parameters: ----------- sleep: Bool, default true to sleep. false to wake. """ return _pyupm_mcp9808.MCP9808_shutDown(self, sleep)
[docs] def setMode(self, celsius=True): """ void setMode(bool celsius=true) setMode - sets temperature reporting mode. Parameters: ----------- celsius: Default is true. If false all temps will be reported in fahrenheit. """ return _pyupm_mcp9808.MCP9808_setMode(self, celsius)
[docs] def isCelsius(self): """ bool isCelsius(void) Returns true if mode is celsius False if fahrenheit. """ return _pyupm_mcp9808.MCP9808_isCelsius(self)
[docs] def isTcrit(self): """ bool isTcrit() Returns true if TCrit threshold has been crossed Reflects the state of the bit based on the most recent readTemp() operation. """ return _pyupm_mcp9808.MCP9808_isTcrit(self)
[docs] def isTupper(self): """ bool isTupper() Returns true if TUpper threshold crossed Reflects the state of the bit based on the most recent readTemp() operation. """ return _pyupm_mcp9808.MCP9808_isTupper(self)
[docs] def isTlower(self): """ bool isTlower() Returns true if TLower threshold crossed. Reflects the state of the bit based on the most recent readTemp() operation. """ return _pyupm_mcp9808.MCP9808_isTlower(self)
[docs] def setMonitorReg(self, reg, value): """ void setMonitorReg(MCP9808_REG reg, float value) Sets the value of TCrit, TUpper,TLower registers. reg - MCP9808_REG enum UPPER_TEMP, LOWER_TEMP or CRIT_TEMP. Parameters: ----------- value: - float value representing the set value """ return _pyupm_mcp9808.MCP9808_setMonitorReg(self, reg, value)
[docs] def getMonitorReg(self, reg): """ float getMonitorReg(MCP9808_REG reg) Returns the current value of TCrit, TUpper, TLower registers. Parameters: ----------- reg: - MCP9808_REG enum UPPER_TEMP, LOWER_TEMP or CRIT_TEMP. """ return _pyupm_mcp9808.MCP9808_getMonitorReg(self, reg)
[docs] def clearInterrupt(self): """ void clearInterrupt(void) Clears the interrupt when ALERT_MODE is set to interrupt output and temp threshold crossed. """ return _pyupm_mcp9808.MCP9808_clearInterrupt(self)
[docs] def setAlertMode(self, command): """ void setAlertMode(uint16_t command) Sets alert mode. Can use values from MCP9808_CONFIG enum. Values can be combined. Parameters: ----------- command: - a combination of options to set desired alert mode. See spcec sheet. """ return _pyupm_mcp9808.MCP9808_setAlertMode(self, command)
[docs] def clearAlertMode(self): """ void clearAlertMode(void) Clears Alert Mode sets all params to default. """ return _pyupm_mcp9808.MCP9808_clearAlertMode(self)
[docs] def setHysteresis(self, value): """ void setHysteresis(MCP9808_CONFIG value) Sets hysteresis value. Parameters: ----------- value: MCP9808_CONFIG enum value HYST_0, HYST_1_5, HYST_3_0 or HYST_6_0 """ return _pyupm_mcp9808.MCP9808_setHysteresis(self, value)
[docs] def getHysteresis(self): """ float getHysteresis() Returns hysteresis setting as a float value. """ return _pyupm_mcp9808.MCP9808_getHysteresis(self)
[docs] def setResolution(self, value): """ void setResolution(MCP9808_RESOLUTION value) Sets resolution of temperature conversion. Parameters: ----------- value: - MCP9808_RESOLUTION enum value. RES_LOW = +0.5 C RES_MEDIUM = +0.25 C RES_HIGH = +0.125 C RES_PRECISION = +0.0625 C (default). """ return _pyupm_mcp9808.MCP9808_setResolution(self, value)
[docs] def getResolution(self): """ float getResolution() Returns float value representing the current resolution setting. """ return _pyupm_mcp9808.MCP9808_getResolution(self)
[docs] def getManufacturer(self): """ uint16_t getManufacturer() Returns Manufacturer ID. Typically 0x0054; """ return _pyupm_mcp9808.MCP9808_getManufacturer(self)
[docs] def getDevicedId(self): """ uint16_t getDevicedId() Returns device ID and revision. Typically 0x0400 With ID in the High byte. """ return _pyupm_mcp9808.MCP9808_getDevicedId(self)
MCP9808_swigregister = _pyupm_mcp9808.MCP9808_swigregister MCP9808_swigregister(MCP9808) # This file is compatible with both classic and new-style classes.