当前位置: 首页>>代码示例>>Python>>正文


Python Adafruit_MotorHAT.RELEASE属性代码示例

本文整理汇总了Python中Adafruit_MotorHAT.Adafruit_MotorHAT.RELEASE属性的典型用法代码示例。如果您正苦于以下问题:Python Adafruit_MotorHAT.RELEASE属性的具体用法?Python Adafruit_MotorHAT.RELEASE怎么用?Python Adafruit_MotorHAT.RELEASE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在Adafruit_MotorHAT.Adafruit_MotorHAT的用法示例。


在下文中一共展示了Adafruit_MotorHAT.RELEASE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_all_motors

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def test_all_motors(cls):
        # Note: motors are 1-indexed, range is 0-indexed, begin at 1, goes to 4
        for each_hat in cls.hat_stack:
            for each_motor in range(1, Motors.motors_on_each_Hat+1):
                try:
                    cls.hat_stack[each_hat].getMotor(each_motor).run(Adafruit_MotorHAT.FORWARD)
                    print "Testing Hat: ", each_hat._i2caddr, " and Motor: ", each_motor
                    time.sleep(1)
                    cls.hat_stack[each_hat].getMotor(each_motor).run(Adafruit_MotorHAT.RELEASE)
                except:  # Not all motors in all Hats will be available
                    print "Nonexistent motor: #{} in HAT: {}".format(each_motor, each_hat._i2caddr)

    ############################################
    # Initialize the motors on the Bot         #
    ############################################
    # Turn off all motors -- this is registered to run at program exit: atexit.register(turn_off_motors)
    # recommended for auto-disabling motors on shutdown! 
开发者ID:kikiorg,项目名称:TikiBot,代码行数:19,代码来源:Motors.py

示例2: stop

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def stop(self):
    self.left_motor.run(Adafruit_MotorHAT.RELEASE)
    self.right_motor.run(Adafruit_MotorHAT.RELEASE) 
开发者ID:PacktPublishing,项目名称:Python-Programming-with-Raspberry-Pi,代码行数:5,代码来源:robot.py

示例3: shutdown

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def shutdown(self):
        self.mh.getMotor(self.motor_num).run(Adafruit_MotorHAT.RELEASE) 
开发者ID:wroscoe,项目名称:donkey,代码行数:4,代码来源:actuator.py

示例4: turnOffMotors

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def turnOffMotors():
    mh.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
    mh.getMotor(2).run(Adafruit_MotorHAT.RELEASE)
    mh.getMotor(3).run(Adafruit_MotorHAT.RELEASE)
    mh.getMotor(4).run(Adafruit_MotorHAT.RELEASE) 
开发者ID:xubonnie,项目名称:velocity_drawer,代码行数:7,代码来源:DualStepperTest.py

示例5: turnOffMotors

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def turnOffMotors():
    tophat.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
    tophat.getMotor(2).run(Adafruit_MotorHAT.RELEASE)
    tophat.getMotor(3).run(Adafruit_MotorHAT.RELEASE)
    tophat.getMotor(4).run(Adafruit_MotorHAT.RELEASE)
    bottomhat.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
    bottomhat.getMotor(2).run(Adafruit_MotorHAT.RELEASE)
    bottomhat.getMotor(3).run(Adafruit_MotorHAT.RELEASE)
    bottomhat.getMotor(4).run(Adafruit_MotorHAT.RELEASE) 
开发者ID:xubonnie,项目名称:velocity_drawer,代码行数:11,代码来源:StackingTest.py

示例6: __init__

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def __init__(self, addr=0x60, left_id=1, right_id=2, left_trim=0, right_trim=0,
                 stop_at_exit=True):
        """Create an instance of the robot.  Can specify the following optional
        parameters:
         - addr: The I2C address of the motor HAT, default is 0x60.
         - left_id: The ID of the left motor, default is 1.
         - right_id: The ID of the right motor, default is 2.
         - left_trim: Amount to offset the speed of the left motor, can be positive
                      or negative and use useful for matching the speed of both
                      motors.  Default is 0.
         - right_trim: Amount to offset the speed of the right motor (see above).
         - stop_at_exit: Boolean to indicate if the motors should stop on program
                         exit.  Default is True (highly recommended to keep this
                         value to prevent damage to the bot on program crash!).
        """
        # Initialize motor HAT and left, right motor.
        self._mh = Adafruit_MotorHAT(addr)
        self._left = self._mh.getMotor(left_id)
        self._right = self._mh.getMotor(right_id)
        self._left_trim = left_trim
        self._right_trim = right_trim
        # Start with motors turned off.
        self._left.run(Adafruit_MotorHAT.RELEASE)
        self._right.run(Adafruit_MotorHAT.RELEASE)
        # Configure all motors to stop at program exit if desired.
        if stop_at_exit:
            atexit.register(self.stop) 
开发者ID:xubonnie,项目名称:velocity_drawer,代码行数:29,代码来源:Robot.py

示例7: stop

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def stop(self):
        """Stop all movement."""
        self._left.run(Adafruit_MotorHAT.RELEASE)
        self._right.run(Adafruit_MotorHAT.RELEASE) 
开发者ID:xubonnie,项目名称:velocity_drawer,代码行数:6,代码来源:Robot.py

示例8: turnOffMotors

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def turnOffMotors():
        mh.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
        mh.getMotor(2).run(Adafruit_MotorHAT.RELEASE)
        mh.getMotor(3).run(Adafruit_MotorHAT.RELEASE)
        mh.getMotor(4).run(Adafruit_MotorHAT.RELEASE) 
开发者ID:xubonnie,项目名称:velocity_drawer,代码行数:7,代码来源:StepperMotor.py

示例9: turn_off_motors

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def turn_off_motors(cls):
        # Note: motors are 1-indexed, range is 0-indexed, begin at 1, goes to 4
        for each_Hat in cls.hat_stack:
            for each_motor in range(1, cls.motors_on_each_Hat+1):
                try:
                    each_Hat.getMotor(each_motor).run(Adafruit_MotorHAT.RELEASE)
                except:  # Not all motors in all Hats will be available, but let's shut them all down anyway
                    print "Nonexistent motor: #", each_motor

    ############################################
    # Turn motor on and leave it on            #
    ############################################
    # Treat motor as output 
开发者ID:kikiorg,项目名称:TikiBot,代码行数:15,代码来源:Motors.py

示例10: turn_off

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def turn_off(self):
        # print "Effect turned off: {}".format(self.name)
        self.motor.run(Adafruit_MotorHAT.RELEASE)

    ###########################################################################################################
    # Thread functions: these are the interface for threaded functions -- just use these
    ###########################################################################################################

    #####################################################
    # Thread: Turn on the motor for a specific time     #
    ##################################################### 
开发者ID:kikiorg,项目名称:TikiBot,代码行数:13,代码来源:Motors.py

示例11: _thread_duration

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def _thread_duration(self, duration, forwards=True):
        self.motor.setSpeed(255)
        self.motor.run(Adafruit_MotorHAT.FORWARD if forwards else Adafruit_MotorHAT.BACKWARD)
        time.sleep(duration)
        self.motor.run(Adafruit_MotorHAT.RELEASE)

    ############################################
    # Ramp the motor speed up -- like a fade   #
    ############################################
    # Slowly raise or lower the speed of the motor.
    # The wait is simply how long the loop takes. 
开发者ID:kikiorg,项目名称:TikiBot,代码行数:13,代码来源:Motors.py

示例12: _thread_ramp

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def _thread_ramp(self, ramp_up=True, forwards=True, step=2):
        for i in range(0 if ramp_up else 255, 255 if ramp_up else -1, step if ramp_up else (-step)):
            self.motor.setSpeed(i)
            self.motor.run(Adafruit_MotorHAT.FORWARD if forwards else Adafruit_MotorHAT.BACKWARD)
        if not ramp_up:
            self.motor.run(Adafruit_MotorHAT.RELEASE)

    ############################################
    # Flash the motor randomly                 #
    ############################################
    # Pick random delay times until it exceeds duration
    # Note: I cheated - the last flash rounds up to duration 
开发者ID:kikiorg,项目名称:TikiBot,代码行数:14,代码来源:Motors.py

示例13: turnOffMotors

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def turnOffMotors():
    # pi hat motors
    mh.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
    mh.getMotor(2).run(Adafruit_MotorHAT.RELEASE)
    mh.getMotor(3).run(Adafruit_MotorHAT.RELEASE)
    mh.getMotor(4).run(Adafruit_MotorHAT.RELEASE) 
开发者ID:runmyrobot,项目名称:runmyrobot,代码行数:8,代码来源:controller.py

示例14: turnoffMotors

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def turnoffMotors():
	mh.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
	mh.getMotor(2).run(Adafruit_MotorHAT.RELEASE)
	mh.getMotor(3).run(Adafruit_MotorHAT.RELEASE)
	mh.getMotor(4).run(Adafruit_MotorHAT.RELEASE) 
开发者ID:codestar12,项目名称:ieee-cs-txst,代码行数:7,代码来源:controller.py

示例15: turnOffMotors

# 需要导入模块: from Adafruit_MotorHAT import Adafruit_MotorHAT [as 别名]
# 或者: from Adafruit_MotorHAT.Adafruit_MotorHAT import RELEASE [as 别名]
def turnOffMotors():
	mh.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
	mh.getMotor(2).run(Adafruit_MotorHAT.RELEASE)
	mh.getMotor(3).run(Adafruit_MotorHAT.RELEASE)
	mh.getMotor(4).run(Adafruit_MotorHAT.RELEASE) 
开发者ID:codestar12,项目名称:ieee-cs-txst,代码行数:7,代码来源:motorcode.py


注:本文中的Adafruit_MotorHAT.Adafruit_MotorHAT.RELEASE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。