Source code for pyupm_l298

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

_pyupm_l298.L298_DEFAULT_PWM_PERIOD_swigconstant(_pyupm_l298)
L298_DEFAULT_PWM_PERIOD = _pyupm_l298.L298_DEFAULT_PWM_PERIOD
[docs]class L298(_object): """ API for the L298 Dual H-Bridge Motor Driver. ID: l298 Name: Dual H-bridge Motor Driver Category: motor Manufacturer: seeed sparkfun Link:https://www.sparkfun.com/products/9670 Connection: gpio pwm It was developed using the RobotBase Dual H-Bridge module. This module can support 2 DC motors, or one 2-phase stepper motor. It requires 3 pins per DC motor (or H-bridge), or 4 pins for the stepper motor (uses both H-bridges). L298 Dual H-Bridge Motor Driver image provided by SparkFun* underCC BY-NC-SA-3.0. Example driving a DC motorExample driving a stepper motor C++ includes: l298.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, L298, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, L298, name) __repr__ = _swig_repr DIR_NONE = _pyupm_l298.L298_DIR_NONE DIR_CW = _pyupm_l298.L298_DIR_CW DIR_CCW = _pyupm_l298.L298_DIR_CCW def __init__(self, *args): """ L298(int stepsPerRev, int en, int i1, int i2, int i3, int i4) L298 constructor for a 4-wire stepper motor Parameters: ----------- stepsPerRev: Number of steps per full revolution en: Enables the pin i1: Digital pin to use for stepper input 1 i2: Digital pin to use for stepper input 2 i3: Digital pin to use for stepper input 3 i4: Digital pin to use for stepper input 4 """ this = _pyupm_l298.new_L298(*args) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_l298.delete_L298 __del__ = lambda self: None
[docs] def getMillis(self): """ uint32_t getMillis() Returns the number of milliseconds elapsed since initClock() was last called. Elapsed milliseconds """ return _pyupm_l298.L298_getMillis(self)
[docs] def initClock(self): """ void initClock() Resets the clock """ return _pyupm_l298.L298_initClock(self)
[docs] def setPeriodMS(self, ms): """ void setPeriodMS(int ms) Sets the period in milliseconds Parameters: ----------- ms: Period in milliseconds """ return _pyupm_l298.L298_setPeriodMS(self, ms)
[docs] def enable(self, enable): """ void enable(bool enable) Enables the PWM output for a motor Parameters: ----------- enable: Enables the PWM output if true, disables if false """ return _pyupm_l298.L298_enable(self, enable)
[docs] def setSpeed(self, speed): """ void setSpeed(int speed) Sets the speed of a DC or stepper motor. For a DC motor, values can range from 0 (off) to 100 (full speed). For a stepper motor, specify the desired RPM. Parameters: ----------- speed: Speed to set the motor to """ return _pyupm_l298.L298_setSpeed(self, speed)
[docs] def setDirection(self, dir): """ void setDirection(L298_DIRECTION_T dir) Sets the direction of the motor, clockwise or counterclockwise Parameters: ----------- dir: Direction to set the motor to """ return _pyupm_l298.L298_setDirection(self, dir)
[docs] def stepperSteps(self, steps): """ void stepperSteps(unsigned int steps) Steps the stepper motor a specified number of steps Parameters: ----------- steps: Number of steps to move the stepper motor """ return _pyupm_l298.L298_stepperSteps(self, steps)
L298_swigregister = _pyupm_l298.L298_swigregister L298_swigregister(L298) # This file is compatible with both classic and new-style classes.