update spv

This commit is contained in:
Paul Pan 2021-08-17 19:01:37 +08:00
parent 89ab6750d7
commit 2eb9499127

View File

@ -18,8 +18,8 @@ def init_serial(pipe_path, baudrate):
def print_map():
print("\033c", end="")
ball = ''
bat = ''
border = ''
bat = ''
border = ''
print(hello)
for i in range(83):
@ -41,25 +41,21 @@ def print_map():
def clear_map():
matrix[pos[0]][0] = 0
if pos[0] < 24:
matrix[pos[0] + 1][0] = 0
matrix[pos[0]][4] = 0
matrix[pos[0] - 1][4] = 0
matrix[pos[1]][80] = 0
if pos[1] < 24:
matrix[pos[1] + 1][80] = 0
matrix[pos[1]][76] = 0
matrix[pos[1] - 1][76] = 0
matrix[pos[3]][pos[2]] = 0
def update_map():
matrix[pos[0]][0] = 1
if pos[0] < 24:
matrix[pos[0] + 1][0] = 1
matrix[pos[0]][4] = 1
matrix[pos[0] - 1][4] = 1
matrix[pos[1]][80] = 1
if pos[1] < 24:
matrix[pos[1] + 1][80] = 1
matrix[pos[1]][76] = 1
matrix[pos[1] - 1][76] = 1
matrix[pos[3]][pos[2]] = 2
@ -89,10 +85,10 @@ def main():
continue
clear_map()
pos[0] = 24 - (line[0] - 129)
pos[1] = 24 - (line[1] - 129)
pos[0] = 25 - (line[0] - 128)
pos[1] = 25 - (line[1] - 128)
pos[2] = line[2] - 129
pos[3] = 24 - (line[3] - 129)
pos[3] = 25 - (line[3] - 128)
update_map()
print_map()
@ -109,10 +105,10 @@ if __name__ == '__main__':
print('Failed to open serial port')
exit(1)
# tty.write('Hello World\n'.encode('utf-8'))
# tty.write('Ping Pong.\n'.encode('utf-8'))
# tty.write(serial.to_bytes([128 + 3, 128 + 12, 128 + 40, 128 + 15, 0x0a]))
# tty.write('pause\n'.encode('utf-8'))
# tty.write('resume\n'.encode('utf-8'))
# tty.write(serial.to_bytes([128 + 25, 128 + 25, 128 + 80, 128 + 1, 0x0a]))
# tty.write(serial.to_bytes([128 + 12, 128 + 8, 128 + 32, 128 + 19, 0x0a]))
main()