31 lines
688 B
Python
31 lines
688 B
Python
from numpy import uint8
|
|
|
|
|
|
def send_hud(buf: list):
|
|
n = len(buf)
|
|
chars = []
|
|
crc = uint8(0xeb + n + n)
|
|
chars.append(0x10)
|
|
chars.append(0x7b)
|
|
chars.append(n + 6)
|
|
if n == 0xa:
|
|
chars.append(0x10)
|
|
chars.append(n)
|
|
chars.append(0x00)
|
|
chars.append(0x00)
|
|
chars.append(0x00)
|
|
chars.append(0x55)
|
|
chars.append(0x15)
|
|
for char in buf:
|
|
crc = uint8(crc + char)
|
|
chars.append(char)
|
|
if char == 0x10:
|
|
chars.append(0x10)
|
|
chars.append((-crc) & 0xff)
|
|
chars.append(0x10)
|
|
chars.append(0x03)
|
|
print(chars)
|
|
print([bytes(chr(char), 'raw_unicode_escape') for char in chars])
|
|
|
|
|
|
send_hud([0x04, 0x01])
|