本文整理汇总了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!
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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 #
#####################################################
示例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.
示例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
示例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)
示例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)
示例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)