def main(ser, start, end): c = [255, 255, 255] cur = 0 while True: os.system('clear') if cur == 0: print("\x1b[41m{:03}\x1b[m {:03} {:03}".format(c[0], c[1], c[2])) elif cur == 1: print("{:03} \x1b[42m{:03}\x1b[m {:03}".format(c[0], c[1], c[2])) elif cur == 2: print("{:03} {:03} \x1b[44m{:03}\x1b[m".format(c[0], c[1], c[2])) send_color(start, end, c[0], c[1], c[2]) k = getKey() if k == UP: if c[cur] < 255: c[cur] += 1 elif k == DOWN: if c[cur] > 0: c[cur] -= 1 elif k == RIGHT: cur = (cur + 1) % 3 elif k == LEFT: cur = (cur - 1) % 3
def readMove(self): """ read and return a move to pass to a board """ k = keypress.getKey() return Game.__dirs.get(k)
runtimes = 0 while 1: #Button Mode Switching if GPIO.input(ModeButton): Mode += 1 if Mode > 2: Mode = 1 #using direct keyboard input if (MODE == 1): #get the current pressed key key = str(keypress.getKey()) #make vehicle run accordingly if key == "w": forward() elif key == "a": leftturn() elif key == "d": rightturn() elif key == "e": read_data.measure() elif key == "q": break else: stopmoving()
def readMove(self): key = keypress.getKey() return key
def readMove(self): return keypress.getKey()
def readMove(self): #Lee un movimiento y lo pasa al tablero k = keypress.getKey() return Game.__dirs.get(k)