Source code for pyupm_my9221

# 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_my9221', [dirname(__file__)])
        except ImportError:
            import _pyupm_my9221
            return _pyupm_my9221
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_my9221', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_my9221 = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_my9221
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_my9221.getVersion()
getVersion = _pyupm_my9221.getVersion
[docs]class MY9221(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, MY9221, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, MY9221, name) __repr__ = _swig_repr def __init__(self, dataPin, clockPin, instances=1): """ MY9221(int dataPin, int clockPin, int instances=1) Instantiates an MY9221 object Parameters: ----------- dataPin: Data pin clockPin: Clock pin instances: Number of daisy-chained my9221s, default 1 """ this = _pyupm_my9221.new_MY9221(dataPin, clockPin, instances) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_my9221.delete_MY9221 __del__ = lambda self: None
[docs] def setAutoRefresh(self, enable): """ void setAutoRefresh(bool enable) Enable or disable auto refresh. When auto refresh is enabled, update the LED display as soon as the internal state changes. When false, the display(s) will not be updated until the refresh() method is called. Parameters: ----------- enable: true to enable auto refresh, false otherwise """ return _pyupm_my9221.MY9221_setAutoRefresh(self, enable)
[docs] def setLED(self, led, on): """ void setLED(int led, bool on) Set an LED to a specific on (high intensity) or off (low intensity) value. Parameters: ----------- led: The LED whose state you wish to change on: true to turn on the LED, false to turn the LED off """ return _pyupm_my9221.MY9221_setLED(self, led, on)
[docs] def setLowIntensityValue(self, intensity): """ void setLowIntensityValue(int intensity) Set the greyscale intensity of an LED in the OFF state. The intensity is a value from 0 (fully off) to 255 (fully on). This will take effect on any future LED set or clear operations. Parameters: ----------- intensity: a value from 0 (fully off) to 255 (fully on) """ return _pyupm_my9221.MY9221_setLowIntensityValue(self, intensity)
[docs] def setHighIntensityValue(self, intensity): """ void setHighIntensityValue(int intensity) Set the greyscale intensity of an LED in the ON state. The intensity is a value from 0 (fully off) to 255 (fully on). This will take effect on any future LED set or clear operations. Parameters: ----------- intensity: a value from 0 (fully off) to 255 (fully on) """ return _pyupm_my9221.MY9221_setHighIntensityValue(self, intensity)
[docs] def setAll(self): """ void setAll() Set all of the LEDS to the ON (high intensity value) state. """ return _pyupm_my9221.MY9221_setAll(self)
[docs] def clearAll(self): """ void clearAll() Set all of the LEDS to the OFF (low intensity value) state. """ return _pyupm_my9221.MY9221_clearAll(self)
[docs] def refresh(self): """ void refresh() Set the LED states to match the internal stored states. This is useful when auto refresh ( setAutoRefresh()) is false to update the display. """ return _pyupm_my9221.MY9221_refresh(self)
MY9221_swigregister = _pyupm_my9221.MY9221_swigregister MY9221_swigregister(MY9221)
[docs]class GroveLEDBar(MY9221): """ API for Grove LED Bars base on the MY9221. ID: groveledbar Name: LED Bar Other Names: MY9221 LED Bar Category: display Manufacturer: seeed Link:http://www.seeedstudio.com/wiki/Grove_-_LED_Bar Connection: gpio Kit: eak This is a 10-segment LED bar, with 8 green segments, 1 yellow segment, and one red segment. They can be daisy chained together so that this module can control multiple LED bars. C++ includes: groveledbar.hpp """ __swig_setmethods__ = {} for _s in [MY9221]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, GroveLEDBar, name, value) __swig_getmethods__ = {} for _s in [MY9221]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, GroveLEDBar, name) __repr__ = _swig_repr def __init__(self, dataPin, clockPin, instances=1): """ GroveLEDBar(int dataPin, int clockPin, int instances=1) Instantiates an GroveLEDBar object Parameters: ----------- dataPin: Data pin clockPin: Clock pin instances: Number of daisy-chained Grove LED Bars, default 1 """ this = _pyupm_my9221.new_GroveLEDBar(dataPin, clockPin, instances) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_my9221.delete_GroveLEDBar __del__ = lambda self: None
[docs] def setBarLevel(self, level, greenToRed=True, barNumber=0): """ void setBarLevel(uint8_t level, bool greenToRed=true, unsigned int barNumber=0) Sets the bar level Parameters: ----------- level: Selected level for the bar (0 - 10). 0 is off greenToRed: true if you start the level on the first green LED, false otherwise barNumber: If you have multiple LED bars chained together, this argument selects a specific bar starting at 0. The default is 0. """ return _pyupm_my9221.GroveLEDBar_setBarLevel(self, level, greenToRed, barNumber)
GroveLEDBar_swigregister = _pyupm_my9221.GroveLEDBar_swigregister GroveLEDBar_swigregister(GroveLEDBar)
[docs]class GroveCircularLED(MY9221): """ API for the Grove Circular LED module. ID: grovecircularled Name: Circular LED Category: display Manufacturer: seeed Link:http://www.seeedstudio.com/wiki/Grove_-_Circular_LED Connection: gpio This is a circular LED ring based on the MY9221 chip. It is often used with a rotary encoder and has 24 controllable LEDs. C++ includes: grovecircularled.hpp """ __swig_setmethods__ = {} for _s in [MY9221]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, GroveCircularLED, name, value) __swig_getmethods__ = {} for _s in [MY9221]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, GroveCircularLED, name) __repr__ = _swig_repr def __init__(self, dataPin, clockPin): """ GroveCircularLED(int dataPin, int clockPin) Instantiates an GroveCircularLED object Parameters: ----------- dataPin: Data pin clockPin: Clock pin """ this = _pyupm_my9221.new_GroveCircularLED(dataPin, clockPin) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_my9221.delete_GroveCircularLED __del__ = lambda self: None
[docs] def setSpinner(self, position): """ void setSpinner(uint8_t position) Sets the spinner (turns off all LEDs but selected one) Parameters: ----------- position: Selected position for the spinner (0-23) """ return _pyupm_my9221.GroveCircularLED_setSpinner(self, position)
[docs] def setLevel(self, level, direction=True): """ void setLevel(uint8_t level, bool direction=true) Sets the lighting status Parameters: ----------- level: Selected level for the circular LED (0-23) direction: Up or down; up is true and default """ return _pyupm_my9221.GroveCircularLED_setLevel(self, level, direction)
GroveCircularLED_swigregister = _pyupm_my9221.GroveCircularLED_swigregister GroveCircularLED_swigregister(GroveCircularLED) # This file is compatible with both classic and new-style classes.