本文整理匯總了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)