-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
38 lines (29 loc) · 884 Bytes
/
test.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
from time import sleep
import serial
import pygame
ser = serial.Serial('COM5', 19200)
def write(s):
ser.write(s.encode('ascii'))
sleep(3)
write('E')
sleep(.2)
write('H')
sleep(10)
pygame.init()
screen = pygame.display.set_mode([1900, 1100])
running = True
while running:
# Look at every event in the queue
for event in pygame.event.get():
# Did the user hit a key?
if event.type == pygame.MOUSEBUTTONDOWN:
x, y = pygame.mouse.get_pos()
print('M %.2f %.2f' % (-(1920 - x) * 330.0 / 1200, y * 330.0 / 1200))
write('M %.2f %.2f' % (-(1920 - x) * 330.0 / 1200, y * 330.0 / 1200))
sleep(.1)
write('L')
write('T')
write('O')
# Did the user click the window close button? If so, stop the loop.
elif event.type == pygame.QUIT:
running = False