-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
44 lines (31 loc) · 842 Bytes
/
main.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
with open("script.usbx", "r") as countline:
length = len(countline.readlines())
countline.close()
script = open("script.usbx", "r")
TAB = " "
INTERPRETERED = """"""
step = 0
while(step < length):
line = script.readline().replace('\n', '').split(" ", 1)
if len(line) > 1:
command = line[0]
argument = line[1]
if command == "TITLE":
res = f"/* {argument}(USBX) */\n"
INTERPRETERED += res
elif command == "TYPE":
res = f'{TAB}Keyboard.print({argument});\n'
INTERPRETERED += res
step += 1
RESULT = """#include "Keyboard.h"
void setup() {
Keyboard.begin();
"""+INTERPRETERED+"""
Keyboard.end();
}
void loop() {}
"""
with open("script.ino", "w") as ino:
ino.write(RESULT)
ino.close()
script.close()