Source code for pyupm_temperature

# 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_temperature', [dirname(__file__)])
        except ImportError:
            import _pyupm_temperature
            return _pyupm_temperature
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_temperature', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_temperature = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_temperature
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_temperature.getVersion()
getVersion = _pyupm_temperature.getVersion
[docs]class Temperature(_object): """ API for NTC Temperature Sensors. ID: temperature Name: Analog Temperature Sensor Other Names: Grove Temperature Sensor Category: temp Manufacturer: seeed Link:http://wiki.seeed.cc/Grove-Temperature_Sensor_V1.2/ Connection: analog Kit: gsk Basic UPM module for analog temperature sensors. These sensors use a NTC thermistor to measure ambient temperature. This driver was developed using the Grove Temperature Sensor. The conversion formula has been updated to work with versions 1.1 and 1.2 of the sensor. For the older v1.0 sensor you will have to specify R0 and B values when initializing the device. The range of this sensor is -40 to 125 C and accuracy is +/- 1.5 C. C++ includes: temperature.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, Temperature, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, Temperature, name) __repr__ = _swig_repr def __init__(self, pin, scale=1.0, r0=100000, b=4275): """ Temperature(unsigned int pin, float scale=1.0, int r0=100000, int b=4275) Analog temperature sensor constructor Parameters: ----------- pin: Analog pin to use scale: Scaling factor for raw analog value from the ADC, useful for mixed 3.3V/5V boards, default 1.0 r0: zero power resistance, this is 100K (default) for v1.1-v1.2 and 10K for v1.0 of the sensor b: thermistor nominal B constant, this is 4275 (default) for v1.1-v1.2 and 3975 for v1.0 of the sensor """ this = _pyupm_temperature.new_Temperature(pin, scale, r0, b) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_temperature.delete_Temperature __del__ = lambda self: None
[docs] def raw_value(self): """ float raw_value() Gets the raw value from the AIO pin Raw value from the ADC """ return _pyupm_temperature.Temperature_raw_value(self)
[docs] def name(self): """ std::string name() Provided for compatibility with old grove base class Sensor name """ return _pyupm_temperature.Temperature_name(self)
[docs] def value(self): """ int value() Gets the temperature in Celsius from the sensor Normalized temperature in Celsius """ return _pyupm_temperature.Temperature_value(self)
Temperature_swigregister = _pyupm_temperature.Temperature_swigregister Temperature_swigregister(Temperature) # This file is compatible with both classic and new-style classes.