本文整理汇总了Python中program.Program.set方法的典型用法代码示例。如果您正苦于以下问题:Python Program.set方法的具体用法?Python Program.set怎么用?Python Program.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类program.Program
的用法示例。
在下文中一共展示了Program.set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GushPiBot
# 需要导入模块: from program import Program [as 别名]
# 或者: from program.Program import set [as 别名]
class GushPiBot(object):
"""
This class controls the menu and programming and operates the main event loop
"""
def __init__(self):
self.components = []
self.active = True
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
def startup(self):
self.create_display()
self.create_menu()
self.create_wheels()
self.create_program()
if BUTTONS_AVAILABLE:
self.create_buttons()
if WEBCAM_AVAILABLE:
self.create_webcam()
if WII_AVAILABLE:
self.create_wiimote()
if ECHO_AVAILABLE:
self.create_echo()
if SPEECH_AVAILABLE:
self.create_speech()
if AUDIO_AVAILABLE:
self.create_audio()
if WEBSERVER_AVAILABLE:
self.create_webserver()
self.create_keyboard()
self.update_menu()
self.display.display_at(1, 0, "Init complete")
def add_component(self, text, component):
self.components.append(component)
self.display.display_at(1, 0, "Created " + text)
def create_display(self):
if LCD_AVAILABLE:
self.display = LCDDisplay()
else:
self.display = ConsoleDisplay()
self.display.display("GushPiBot...")
self.display_ip()
self.add_component("Display", self.display)
def create_wheels(self):
self.wheels = Wheels()
self.add_component("Wheels", self.wheels)
def create_program(self):
self.command = 0
self.program = Program(self.display)
self.program.add_command("^", "Forward", self.wheels.forwards, self.wheels.stop)
self.program.add_command("v", "Backward", self.wheels.backwards, self.wheels.stop)
self.program.add_command("<", "Left", self.wheels.left, self.wheels.stop)
self.program.add_command(">", "Right", self.wheels.right, self.wheels.stop)
self.program.add_command("{", "Slow Left", self.wheels.slow_left, self.wheels.stop)
self.program.add_command("}", "Slow Right", self.wheels.slow_right, self.wheels.stop)
self.add_component("Program", self.program)
def create_buttons(self):
self.buttons = Buttons()
self.buttons.handlers["MENU"].add(self.menu.next)
self.buttons.handlers["SELECT"].add(self.menu.select)
self.add_component("Buttons", self.buttons)
def create_webcam(self):
self.webcam = Webcam()
self.program.add_command("#", "Photo", self.webcam.take_photo)
self.add_component("Webcam", self.webcam)
def create_wiimote(self):
self.wiimote = Wiimote(self.display)
self.wiimote.handlers["UP"].add(self.wheels.forwards)
self.wiimote.handlers["DOWN"].add(self.wheels.backwards)
self.wiimote.handlers["LEFT"].add(self.wheels.left)
self.wiimote.handlers["RIGHT"].add(self.wheels.right)
self.wiimote.handlers["A"].add(self.wheels.stop)
try:
self.wiimote.handlers["B"].add(self.webcam.take_photo)
except AttributeError:
pass
self.wiimote.handlers["HOME"].add(self.menu.select)
self.wiimote.handlers["MINUS"].add(self.menu.prev)
self.wiimote.handlers["PLUS"].add(self.menu.next)
self.wiimote.stop_handler = self.wheels.stop
self.add_component("Wiimote", self.wiimote)
def create_speech(self):
self.speech = Speech()
self.speech.speak("Hello. I am Gush Pi Bot.")
self.wheels.speech_handler.add(self.speech.speak)
self.add_component("Speech", self.speech)
def create_audio(self):
self.audio = Audio()
self.add_component("Audio", self.audio)
def create_echo(self):
#.........这里部分代码省略.........