本文整理汇总了Python中motor.Motor.setmin方法的典型用法代码示例。如果您正苦于以下问题:Python Motor.setmin方法的具体用法?Python Motor.setmin怎么用?Python Motor.setmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类motor.Motor
的用法示例。
在下文中一共展示了Motor.setmin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import setmin [as 别名]
class ZMQMotor:
def __init__(self, address, pin, maxthrottle=200, minthrottle=500, name="motor"):
self.name = name
self.address = address
self.server = ZMQServer(address)
self.motor = Motor(pin, minthrottle, maxthrottle)
self.motor.setmin()
self.quit = False
self.engage()
def engage(self):
self.mainloop()
def mainloop(self):
while not self.quit:
try:
message = self.server.receive()
self.process_msg(message)
self.reply(message)
time.sleep(1)
except ZMQError as e:
pass
self.destroy()
def process_msg(self, message):
match = THROTTLE_REGEX.match(message)
print "Received message: " + message
if message == "laputanmachine":
self.quit=True
elif match:
throttle = int(match.group('throttle'))
self.motor.set_throttle(throttle)
else:
print message
def reply(self, message):
self.server.reply(message)
def destroy(self):
self.motor.stop()
self.server.destroy()
示例2: Motor
# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import setmin [as 别名]
#standard modules
import Tkinter as tk
#my modules
from motor import Motor
m = Motor(17, 500, 200)
m.setmin()
r = raw_input("Press a key to continue")
ct = 0
def onKeyPress(event):
#print event.char
global ct
global m
if event.char == '+':
ct -=1
elif event.char == '-':
ct +=1
elif event.char == 's':
m.stop()
exit()
print ct
m.set_percent(ct)
print m.throttle
root = tk.Tk()
root.geometry('1x1')
root.bind("<KeyPress>", onKeyPress)