Source code for pyupm_grovespeaker

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

_pyupm_grovespeaker.HIGH_swigconstant(_pyupm_grovespeaker)
HIGH = _pyupm_grovespeaker.HIGH

_pyupm_grovespeaker.LOW_swigconstant(_pyupm_grovespeaker)
LOW = _pyupm_grovespeaker.LOW
[docs]class NoteData(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, NoteData, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, NoteData, name) __repr__ = _swig_repr __swig_setmethods__["delayTimeLow"] = _pyupm_grovespeaker.NoteData_delayTimeLow_set __swig_getmethods__["delayTimeLow"] = _pyupm_grovespeaker.NoteData_delayTimeLow_get if _newclass: delayTimeLow = _swig_property(_pyupm_grovespeaker.NoteData_delayTimeLow_get, _pyupm_grovespeaker.NoteData_delayTimeLow_set) __swig_setmethods__["delayTimeLowSharp"] = _pyupm_grovespeaker.NoteData_delayTimeLowSharp_set __swig_getmethods__["delayTimeLowSharp"] = _pyupm_grovespeaker.NoteData_delayTimeLowSharp_get if _newclass: delayTimeLowSharp = _swig_property(_pyupm_grovespeaker.NoteData_delayTimeLowSharp_get, _pyupm_grovespeaker.NoteData_delayTimeLowSharp_set) __swig_setmethods__["delayTimeMed"] = _pyupm_grovespeaker.NoteData_delayTimeMed_set __swig_getmethods__["delayTimeMed"] = _pyupm_grovespeaker.NoteData_delayTimeMed_get if _newclass: delayTimeMed = _swig_property(_pyupm_grovespeaker.NoteData_delayTimeMed_get, _pyupm_grovespeaker.NoteData_delayTimeMed_set) __swig_setmethods__["delayTimeMedSharp"] = _pyupm_grovespeaker.NoteData_delayTimeMedSharp_set __swig_getmethods__["delayTimeMedSharp"] = _pyupm_grovespeaker.NoteData_delayTimeMedSharp_get if _newclass: delayTimeMedSharp = _swig_property(_pyupm_grovespeaker.NoteData_delayTimeMedSharp_get, _pyupm_grovespeaker.NoteData_delayTimeMedSharp_set) __swig_setmethods__["delayTimeHigh"] = _pyupm_grovespeaker.NoteData_delayTimeHigh_set __swig_getmethods__["delayTimeHigh"] = _pyupm_grovespeaker.NoteData_delayTimeHigh_get if _newclass: delayTimeHigh = _swig_property(_pyupm_grovespeaker.NoteData_delayTimeHigh_get, _pyupm_grovespeaker.NoteData_delayTimeHigh_set) __swig_setmethods__["delayTimeHighSharp"] = _pyupm_grovespeaker.NoteData_delayTimeHighSharp_set __swig_getmethods__["delayTimeHighSharp"] = _pyupm_grovespeaker.NoteData_delayTimeHighSharp_get if _newclass: delayTimeHighSharp = _swig_property(_pyupm_grovespeaker.NoteData_delayTimeHighSharp_get, _pyupm_grovespeaker.NoteData_delayTimeHighSharp_set) def __init__(self): this = _pyupm_grovespeaker.new_NoteData() try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_grovespeaker.delete_NoteData __del__ = lambda self: None
NoteData_swigregister = _pyupm_grovespeaker.NoteData_swigregister NoteData_swigregister(NoteData)
[docs]class GroveSpeaker(_object): """ API for the Grove Speaker. Deprecated This class is being replaced by Speaker ID: grovespeaker Name: Speaker Module Category: sound Manufacturer: seeed Connection: gpio Kit: hak UPM module for the Grove Speaker. This sensor can generate different tones and sounds depending on the frequency of the input signal. C++ includes: grovespeaker.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, GroveSpeaker, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, GroveSpeaker, name) __repr__ = _swig_repr def __init__(self, pin): """ GroveSpeaker(int pin) Grove Speaker constructor Parameters: ----------- pin: Digital pin to use """ this = _pyupm_grovespeaker.new_GroveSpeaker(pin) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_grovespeaker.delete_GroveSpeaker __del__ = lambda self: None
[docs] def playAll(self): """ void playAll() Plays all alto notes (lowest notes) """ return _pyupm_grovespeaker.GroveSpeaker_playAll(self)
[docs] def playSound(self, letter, sharp, vocalWeight): """ void playSound(char letter, bool sharp, std::string vocalWeight) Plays a sound and a note whether it's sharp or not Parameters: ----------- letter: Character name of the note ('a', 'b', 'c', 'd', 'e', 'f', or 'g') sharp: If true, plays a sharp version of the note; otherwise, does not play the note vocalWeight: String to determine whether to play a low ("low"), a medium ("med"), or a high ("high") note """ return _pyupm_grovespeaker.GroveSpeaker_playSound(self, letter, sharp, vocalWeight)
GroveSpeaker_swigregister = _pyupm_grovespeaker.GroveSpeaker_swigregister GroveSpeaker_swigregister(GroveSpeaker) # This file is compatible with both classic and new-style classes.