當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。