Yeah! I did it
Just changes a little bit that while True loop.
python code:
while True:
for event in pygame.event.get():
if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
return
>>> key = pygame.key.get_pressed() # Added only to check the condition below<<<
>>> while key[K_UP] or key[K_DOWN] or key[K_RIGHT] or key[K_LEFT]<<<
key = pygame.key.get_pressed()
if key[K_UP] and key[K_RIGHT]:
SendData('AD')
elif key[K_UP] and key[K_LEFT]:
SendData('AE')
elif key[K_DOWN] and key[K_RIGHT]:
SendData('RD')
elif key[K_DOWN] and key[K_LEFT]:
SendData('RE')
elif key[K_UP]:
SendData('Ax')
elif key[K_DOWN]:
SendData('Rx')
elif key[K_RIGHT]:
SendData('xD')
elif key[K_LEFT]:
SendData('xE')
>>> pygame.time.delay(10) # Added to have a better control - 10 ms between each loop<<<
>>> pygame.event.pump() # This makes the trick, but I don't know exactly how it works<<<
Also, already added the command to send data via serial.