Source code for pyupm_dfrph

# 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_dfrph', [dirname(__file__)])
        except ImportError:
            import _pyupm_dfrph
            return _pyupm_dfrph
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_dfrph', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_dfrph = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_dfrph
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_dfrph.getVersion()
getVersion = _pyupm_dfrph.getVersion
[docs]class DFRPH(_object): """ API for the DFRobot pH Sensors. ID: dfrph Name: Analog pH Sensor Category: liquid Manufacturer: dfrobot Link:http://www.dfrobot.com/index.php?route=product/product&product_id=1110 Connection: analog This sensor family returns an analog voltage proportional to the acidity or alkalinity of a liquid it's pH value. This driver was developed using the DFRobot Analog pH meter and the DFRobot Analog pH Meter Pro. Calibration instructions, taken and slightly reworded from the DFRobot wiki at:http://dfrobot.com/wiki/index.php/PH_meter%28SKU:_SEN0161%29 1) Connect equipment: the pH electrode is connected to the BNC connector on the pH meter board, and then the pH meter board is connected to the analog port 0 of the controller. When the controller gets power, you will see the blue LED on board is on. 2) Put the pH electrode into the standard solution whose pH value is 7.00. Run the dfrph example and note the pH output value. Compare the value with 7.00, and calculate the difference. This is the value you should supply to the setOffset() method. 3) Put the pH electrode into the pH standard solution whose value is 4.00. Then wait about one minute, and adjust the potentiometer on the interface board. Let the value stabilise at around 4.00. At this time,the acidic calibration has been completed and you can measure the pH value of an acidic solution. 4) According to the linear characteristics of pH electrode itself, after the above calibration,you can directly measure the pH value of the alkaline solution. If you want to get better accuracy, you can recalibrate it. Alkaline calibration use the standard solution whose pH value is 9.18. Also adjust the potentiometer and let the value stabilise at around 9.18. After this calibration, you can measure the pH value of an alkaline solution. C++ includes: dfrph.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, DFRPH, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, DFRPH, name) __repr__ = _swig_repr def __init__(self, pin, vref=5.0): """ DFRPH(int pin, float vref=5.0) DFRPH constructor Parameters: ----------- pin: Analog pin to use vref: Analog reference voltage; default is 5.0 V """ this = _pyupm_dfrph.new_DFRPH(pin, vref) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_dfrph.delete_DFRPH __del__ = lambda self: None
[docs] def setOffset(self, offset): """ void setOffset(float offset) Specifies the offset determined from calibration. The default is 0.0. Parameters: ----------- offset: The offset value to use """ return _pyupm_dfrph.DFRPH_setOffset(self, offset)
[docs] def setScale(self, scale): """ void setScale(float scale) Specifies the scale determined from calibration. The default is 1.0. Parameters: ----------- scale: The scale value to use """ return _pyupm_dfrph.DFRPH_setScale(self, scale)
[docs] def volts(self): """float volts() """ return _pyupm_dfrph.DFRPH_volts(self)
[docs] def pH(self, samples=15): """ float pH(unsigned int samples=15) Take a number of samples and return the detected pH value. The default number of samples is 15. Parameters: ----------- samples: The number of samples to average over, default 15 The pH value detected """ return _pyupm_dfrph.DFRPH_pH(self, samples)
DFRPH_swigregister = _pyupm_dfrph.DFRPH_swigregister DFRPH_swigregister(DFRPH) # This file is compatible with both classic and new-style classes.