-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathruntime.py
More file actions
47 lines (39 loc) · 1.01 KB
/
Copy pathruntime.py
File metadata and controls
47 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python3.4
import curses
import buggy
import time
print('\nWaking robot...\n')
bot = buggy.buggyBot()
print('Initialising Systems\n')
bot.update() ## Initialise all systems
actions = {
curses.KEY_UP: bot.forwards,
curses.KEY_DOWN: bot.backwards,
curses.KEY_LEFT: bot.turn_left,
curses.KEY_RIGHT: bot.turn_right
}
def main(window):
next_key = None
while True:
curses.halfdelay(1)
if next_key is None:
key = window.getch()
else:
key = next_key
next_key = None
if key != -1:
# KEY DOWN
curses.halfdelay(3)
action = actions.get(key)
if action is not None:
action()
bot.update()
time.sleep(.33)
next_key = key
while next_key == key:
next_key = window.getch()
# KEY UP
bot.stop
if __name__ == '__main__':
print("\nLet's do this!!\n")
curses.wrapper(main)