1
0
Fork 0

hexadecimal always expressed as two characters

This commit is contained in:
Kevin Matz 2019-07-30 12:56:16 -04:00
parent a754c74165
commit fef6a9ed8d
1 changed files with 5 additions and 2 deletions

View File

@ -34,8 +34,11 @@ class Robot:
self.buffer = bytes()
def move(self):
hexval = [hex(dec).lstrip("0x").rstrip("L") for dec in self.target]
str = '{'+','.join(hexval)+'}'
hexvals = [hex(dec).lstrip("0x").rstrip("L") for dec in self.target]
for index, hexval in enumerate(hexvals):
if len(hexvals[index]) < 2:
hexvals[index] = "0" + hexval
str = '{'+','.join(hexvals)+'}\n'
str = str.lower().encode()
try:
self.serial_port.write(str)