-
Notifications
You must be signed in to change notification settings - Fork 0
/
ARM_GUI_CONNECT_METHOD.py
108 lines (84 loc) · 3.56 KB
/
ARM_GUI_CONNECT_METHOD.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import sys
import socket
import pygame
from pygame.locals import *
import sys
s = socket.socket()
print("Socket successfully created")
port = 80
s.bind(("192.168.46.35", 27339))
print("socket binded to %s" % (port))
s.listen(5)
print("socket is listening")
c, addr = s.accept()
print('Got connection from', addr)
def dataPacket(data, data1, data2, data3, data4, data5):
sendData("m" + "s" + data + "f" + data1 +
"n" + data2 + data3 + data4 + data5)
def sendData(me):
while True:
c.send(me.encode())
return
pygame.init()
display = pygame.display.set_mode((300, 300))
while (1):
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_a:
print("Key A has been pressed")
sendData(me='a')
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')
if event.type == pygame.KEYUP:
if event.key == pygame.K_a:
print("Key A has been released")
sendData(me='ar')
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_b:
print("Key B has been pressed")
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')
if event.type == pygame.KEYUP:
if event.key == pygame.K_b:
print("Key B has been released")
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_s:
print("Key S has been pressed")
sendData(me='s')
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')
if event.type == pygame.KEYUP:
if event.key == pygame.K_s:
print("Key S has been released")
sendData(me='sr')
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_d:
print("Key D has been pressed")
sendData(me='d')
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')
if event.type == pygame.KEYUP:
if event.key == pygame.K_d:
print("Key D has been released")
sendData(me='dr')
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
print("Key W has been pressed")
sendData(me='w')
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')
if event.type == pygame.KEYUP:
if event.key == pygame.K_w:
print("Key W has been released")
sendData(me='wr')
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_z:
print("Key Z has been pressed")
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')
if event.type == pygame.KEYUP:
if event.key == pygame.K_z:
print("Key Z has been released")
# dataPacket(data='rl',data1='0',data2='0',data3='0',data4='0',data5='0')