Source code for pyupm_grove

# 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_grove', [dirname(__file__)])
        except ImportError:
            import _pyupm_grove
            return _pyupm_grove
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_grove', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_grove = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_grove
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_grove.getVersion()
getVersion = _pyupm_grove.getVersion
[docs]class Grove(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, Grove, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, Grove, name) __repr__ = _swig_repr __swig_destroy__ = _pyupm_grove.delete_Grove __del__ = lambda self: None
[docs] def name(self): """std::string name() """ return _pyupm_grove.Grove_name(self)
def __init__(self): this = _pyupm_grove.new_Grove() try: self.this.append(this) except Exception: self.this = this
Grove_swigregister = _pyupm_grove.Grove_swigregister Grove_swigregister(Grove)
[docs]class GroveButton(Grove): """ API for the Grove Button. Deprecated This class is being replaced by the upm-button library and the Button class. ID: grovebutton Name: Button Other Names: Grove Touch Sensor Category: button touch Manufacturer: seeed Connection: gpio Kit: gsk Basic UPM module for the Grove button C++ includes: grovebutton.hpp """ __swig_setmethods__ = {} for _s in [Grove]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, GroveButton, name, value) __swig_getmethods__ = {} for _s in [Grove]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, GroveButton, name) __repr__ = _swig_repr def __init__(self, pin): """ GroveButton(unsigned int pin) Grove button constructor Parameters: ----------- pin: Pin to use """ this = _pyupm_grove.new_GroveButton(pin) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_grove.delete_GroveButton __del__ = lambda self: None
[docs] def name(self): """ std::string name() Gets the name of the sensor Name of this sensor """ return _pyupm_grove.GroveButton_name(self)
[docs] def value(self): """ int value() Gets the value from the GPIO pin Value from the GPIO pin """ return _pyupm_grove.GroveButton_value(self)
[docs] def installISR(self, level, isr, arg): """ void installISR(mraa::Edge level, void(*isr)(void *), void *arg) Installs an interrupt service routine (ISR) to be called when the button is activated or deactivated. Parameters: ----------- fptr: Pointer to a function to be called on interrupt arg: Pointer to an object to be supplied as an argument to the ISR. """ return _pyupm_grove.GroveButton_installISR(self, level, isr, arg)
[docs] def uninstallISR(self): """ void uninstallISR() Uninstalls the previously installed ISR """ return _pyupm_grove.GroveButton_uninstallISR(self)
GroveButton_swigregister = _pyupm_grove.GroveButton_swigregister GroveButton_swigregister(GroveButton)
[docs]class GroveLed(Grove): """ API for the Grove LED. Deprecated This class is being replaced by the upm-led library and the Led class. ID: groveled Name: LED Category: led Manufacturer: seeed Connection: gpio Kit: gsk UPM module for the Grove LED (or other similar light- emitting diodes). An LED is a small lightbulb that emits light in response to a small current. The longer wire of an LED connects to the positive seat (anode); the shorter wire connects to the negative seat (cathode). The flat side of the bulb corresponds to the cathode, while the rounded side corresponds to the anode. C++ includes: groveled.hpp """ __swig_setmethods__ = {} for _s in [Grove]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, GroveLed, name, value) __swig_getmethods__ = {} for _s in [Grove]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, GroveLed, name) __repr__ = _swig_repr def __init__(self, pin): """ GroveLed(int pin) Grove LED constructor Parameters: ----------- pin: Pin to use """ this = _pyupm_grove.new_GroveLed(pin) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_grove.delete_GroveLed __del__ = lambda self: None
[docs] def write(self, value): """ mraa_result_t write(int value) Turns the LED on or off, depending on the value. If the value is positive (greater than or equal to 1), the LED is turned on. Otherwise, for 0 or negative values, the LED is turned off. Parameters: ----------- value: Tells the LED to turn on (for values >=1) or off (for values <1) 0 if successful, non-zero otherwise """ return _pyupm_grove.GroveLed_write(self, value)
[docs] def off(self): """ mraa_result_t off() Turns the LED off 0 if successful, non-zero otherwise """ return _pyupm_grove.GroveLed_off(self)
[docs] def on(self): """ mraa_result_t on() Turns the LED on 0 if successful, non-zero otherwise """ return _pyupm_grove.GroveLed_on(self)
GroveLed_swigregister = _pyupm_grove.GroveLed_swigregister GroveLed_swigregister(GroveLed)
[docs]class GroveLight(Grove): """ API for the Grove Light Sensor. Deprecated This class is being replaced by the upm-light library and the Light class. ID: grovelight Name: Light Sensor Category: light Manufacturer: seeed Connection: analog Kit: gsk The Grove light sensor detects the intensity of the ambient light. As the light intensity of the environment increases, the resistance of the sensor decreases. This means the raw value from the analog pin is larger in bright light and smaller in the dark. An approximate lux value can also be returned. C++ includes: grovelight.hpp """ __swig_setmethods__ = {} for _s in [Grove]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, GroveLight, name, value) __swig_getmethods__ = {} for _s in [Grove]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, GroveLight, name) __repr__ = _swig_repr def __init__(self, pin): """ GroveLight(unsigned int pin) Grove analog light sensor constructor Parameters: ----------- pin: Analog pin to use """ this = _pyupm_grove.new_GroveLight(pin) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_grove.delete_GroveLight __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_grove.GroveLight_raw_value(self)
[docs] def value(self): """ int value() Gets an approximate light value, in lux, from the sensor Normalized light reading in lux """ return _pyupm_grove.GroveLight_value(self)
GroveLight_swigregister = _pyupm_grove.GroveLight_swigregister GroveLight_swigregister(GroveLight)
[docs]class GroveRelay(Grove): """ API for the Grove Relay. Deprecated This class is being replaced by the upm-relay library and the Relay class. ID: groverelay Name: Relay Category: relay Manufacturer: seeed Connection: gpio Kit: gsk eak hak UPM module for the Grove relay switch. The Grove relay is a digital normally-open switch that uses low voltage or current to control a higher voltage and/or higher current. When closed, the indicator LED lights up and current is allowed to flow. C++ includes: groverelay.hpp """ __swig_setmethods__ = {} for _s in [Grove]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, GroveRelay, name, value) __swig_getmethods__ = {} for _s in [Grove]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, GroveRelay, name) __repr__ = _swig_repr def __init__(self, pin): """ GroveRelay(unsigned int pin) Grove relay constructor Parameters: ----------- pin: Pin to use """ this = _pyupm_grove.new_GroveRelay(pin) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_grove.delete_GroveRelay __del__ = lambda self: None
[docs] def on(self): """ mraa_result_t on() Sets the relay switch to on (closed). This allows current to flow and lights up the indicator LED. 0 if successful, non-zero otherwise """ return _pyupm_grove.GroveRelay_on(self)
[docs] def off(self): """ mraa_result_t off() Sets the relay switch to off (open). This stops current from flowing and the indicator LED is not lit. 0 if successful, non-zero otherwise """ return _pyupm_grove.GroveRelay_off(self)
[docs] def isOn(self): """ bool isOn() Defines whether the relay switch is closed. True if the switch is on (closed), false otherwise """ return _pyupm_grove.GroveRelay_isOn(self)
[docs] def isOff(self): """ bool isOff() Defines whether the relay switch is open. True if the switch is off (open), false otherwise """ return _pyupm_grove.GroveRelay_isOff(self)
GroveRelay_swigregister = _pyupm_grove.GroveRelay_swigregister GroveRelay_swigregister(GroveRelay)
[docs]class GroveRotary(Grove): """ API for the Grove Rotary Angle Sensor (Knob) Deprecated This class is being replaced by the upm-rotary library and the Rotary class. ID: groverotary Name: Rotary Angle Sensor Other Names: Rotary Potentiometer Category: ainput Manufacturer: seeed Connection: analog Kit: gsk Basic UPM module for the Grove rotary angle sensor (knob) on analog. Provides a set of functions to read the absolute pin value, degrees or radians, and another set to do the same relative to the center of the knob's range. C++ includes: groverotary.hpp """ __swig_setmethods__ = {} for _s in [Grove]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, GroveRotary, name, value) __swig_getmethods__ = {} for _s in [Grove]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, GroveRotary, name) __repr__ = _swig_repr def __init__(self, pin): """ GroveRotary(unsigned int pin) Grove rotary angle sensor constructor Parameters: ----------- pin: Number of the analog pin to use """ this = _pyupm_grove.new_GroveRotary(pin) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_grove.delete_GroveRotary __del__ = lambda self: None
[docs] def abs_value(self): """ float abs_value() Gets the absolute raw value from the AIO pin Unsigned value from the ADC """ return _pyupm_grove.GroveRotary_abs_value(self)
[docs] def abs_deg(self): """ float abs_deg() Gets absolute raw degrees from the AIO pin Unsigned degrees from the ADC """ return _pyupm_grove.GroveRotary_abs_deg(self)
[docs] def abs_rad(self): """ float abs_rad() Gets absolute raw radians from the AIO pin Unsigned radians from the ADC """ return _pyupm_grove.GroveRotary_abs_rad(self)
[docs] def rel_value(self): """ float rel_value() Gets the relative value from the AIO pin Signed value from the ADC """ return _pyupm_grove.GroveRotary_rel_value(self)
[docs] def rel_deg(self): """ float rel_deg() Gets relative degrees from the AIO pin Signed degrees from the ADC """ return _pyupm_grove.GroveRotary_rel_deg(self)
[docs] def rel_rad(self): """ float rel_rad() Gets relative radians from the AIO pin Signed radians from the ADC """ return _pyupm_grove.GroveRotary_rel_rad(self)
GroveRotary_swigregister = _pyupm_grove.GroveRotary_swigregister GroveRotary_swigregister(GroveRotary)
[docs]class GroveSlide(Grove): """ API for the Grove Slide Potentiometer. Deprecated This class is being replaced by the upm-slide library and the Slide class. ID: groveslide Name: Slide Potentiometer Category: ainput Manufacturer: seeed Connection: analog Basic UPM module for the Grove slide potentiometer on analog that returns either a raw value or a scaled voltage value. C++ includes: groveslide.hpp """ __swig_setmethods__ = {} for _s in [Grove]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, GroveSlide, name, value) __swig_getmethods__ = {} for _s in [Grove]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, GroveSlide, name) __repr__ = _swig_repr def __init__(self, pin, ref_voltage=5.0): """ GroveSlide(unsigned int pin, float ref_voltage=5.0) Grove analog slide potentiometer constructor Parameters: ----------- pin: Number of the analog pin to use ref_voltage: Reference voltage the board is set to, as a floating- point value; default is 5.0V """ this = _pyupm_grove.new_GroveSlide(pin, ref_voltage) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_grove.delete_GroveSlide __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_grove.GroveSlide_raw_value(self)
[docs] def voltage_value(self): """ float voltage_value() Gets the voltage value from the pin Voltage reading based on the reference voltage """ return _pyupm_grove.GroveSlide_voltage_value(self)
[docs] def ref_voltage(self): """ float ref_voltage() Gets the board's reference voltage passed on object initialization Reference voltage the class was set for """ return _pyupm_grove.GroveSlide_ref_voltage(self)
GroveSlide_swigregister = _pyupm_grove.GroveSlide_swigregister GroveSlide_swigregister(GroveSlide)
[docs]class GroveTemp(Grove): """ API for the Grove Temperature Sensor. Deprecated This class is being replaced by the upm-temperature library and the Temperature class. ID: grovetemp Name: Temperature Sensor Category: temp Manufacturer: seeed Connection: analog Kit: gsk Basic UPM module for the Grove temperature sensor on analog. This sensor uses a thermistor to measure ambient temperature. 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: grovetemp.hpp """ __swig_setmethods__ = {} for _s in [Grove]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, GroveTemp, name, value) __swig_getmethods__ = {} for _s in [Grove]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, GroveTemp, name) __repr__ = _swig_repr def __init__(self, pin, scale=1.0, r0=100000, b=4275): """ GroveTemp(unsigned int pin, float scale=1.0, int r0=100000, int b=4275) Grove 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_grove.new_GroveTemp(pin, scale, r0, b) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_grove.delete_GroveTemp __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_grove.GroveTemp_raw_value(self)
[docs] def value(self): """ int value() Gets the temperature in Celsius from the sensor Normalized temperature in Celsius """ return _pyupm_grove.GroveTemp_value(self)
GroveTemp_swigregister = _pyupm_grove.GroveTemp_swigregister GroveTemp_swigregister(GroveTemp) # This file is compatible with both classic and new-style classes.