-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (29 loc) · 787 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
import ns_detector
import serial, keyboard
import threading, time
D = ns_detector.ns_detector()
def communicator():
last = False
portx = "COM7"
bps = 9600
timex = 0.1
ser = serial.Serial(portx, bps, timeout=timex)
while True:
busy = ser.read().decode()
if busy == "t":
keyboard.press("home")
elif busy == "f":
keyboard.release("home")
if D.RECV:
if not last:
ser.write("t\n".encode())
last = True
else:
if last:
ser.write("f\n".encode())
last = False
def main():
communication = threading.Thread(target=communicator, name="Communicator")
communication.daemon = True
communication.start()
main()