# sys.stdout.write(message) def writeFile(text): # デバッグファイル出力機能 f = open(debugFile, 'r') textBefore = "" for row in f: textBefore = textBefore + row f.close() f = open(debugFile, 'w') f.write(textBefore + text + "\n") f.close() # サーボの初期化 bez = bezelie.Control() # べゼリー操作インスタンスの生成 bez.moveCenter() # サーボの回転位置をトリム値に合わせる # メインループ def main(): try: subprocess.call('amixer cset numid=1 ' + vol + '% -q', shell=True) # スピーカー音量 subprocess.call("sh " + ttsFile + " " + u"顔認識モード", shell=True) stageAngle = 0 # ステージの初期角度 stageDelta = 5 # ループごとにステージを回転させる角度 stageSpeed = 8 # ループごとにステージを回転させる速度 bez.moveHead(15) with picamera.PiCamera() as camera: # Open Pi-Camera as camera with picamera.array.PiRGBArray(
if command_data[1] == u'stage': self.bezelie.moveStage(value) if __name__ == '__main__': scratchhost = '127.0.0.1' # 引数処理 param = sys.argv if len(param) > 1: # 引数がついていればScratchの接続先として利用 scratchhost = param[1] # Bezelieと接続しコントロールするためのインスタンス生成 bez = bezelie.Control() bez.setTrim(head=7, back=2, stage=2) # Scratch接続のためのインスタンス生成 rcv = Receiver(bez) rsc = scratch.RemoteSensorConnection(rcv.broadcast_handler, rcv.sonsor_update_handler) try: rsc.connect(host=scratchhost) except: print 'Cann not connect Scratch on ' + scratchhost exit() print 'Connected to Scratch on ' + scratchhost while (True): try: