-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpytocs.py
32 lines (26 loc) · 904 Bytes
/
pytocs.py
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
#send instrustions array in form of C#
def updatePath(instructions):
file_ = open("firmware.ino", "r")
message = ""
for row in file_:
if ("loop()" not in row):
#print(row)
message = message + row
else:
break
file_.close()
file_ = open("firmware.ino", "w")
message = message + "void loop(){"
#instructions
instructions_code = ""
for instruction in instructions:
if instruction == "left":
instructions_code = instructions_code + " NinetyLeft();"
if instruction == "right":
instructions_code = instructions_code + " NinetyRight();"
if instruction == "forward":
instructions_code = instructions_code + " OneSpaceForward();"
#instructions end
message = message + instructions_code + " return;}"
file_.write(message)
file_.close()