예제 #1
0
파일: server.py 프로젝트: llqgit/pi
def handle_event(payload):
    type = payload['type']
    if type == 'move':
        x = payload['x']
        y = payload['y']
        #print str(x) + ' ' + str(y)
        motor.move(x, y)
    elif type == 'up':
        motor.up()
    elif type == 'down':
        motor.down()
    elif type == 'left':
        motor.left()
    elif type == 'right':
        motor.right()
예제 #2
0
파일: web.py 프로젝트: llqgit/pi
def down():
    motor.down()
    return 'down'
예제 #3
0
import player
import listen
from pynput.keyboard import Controller, Key, Listener
# create IPv4, TCP socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('119.23.228.189', 9999))
print("链接成功")  # read 1024 byte from socket

while 1:
    # if a == "q":
    #     break
    # s.send(a.encode())
    # print("send"+a)
    while True:
        a = s.recv(1024)
        print(a)
        print(a == bytes('w'.encode()))
        print(type(a))
        if a == bytes('w'.encode()):
            motor.up()
        elif a == bytes('s'.encode()):
            motor.down()
        elif a == bytes('d'.encode()):
            motor.right()
        elif a == bytes('a'.encode()):
            motor.left()
        elif a == bytes('b'.encode()):
            player.sound()
        else:
            print("不可以输入", a)