hexadecimal always expressed as two characters
This commit is contained in:
parent
a754c74165
commit
fef6a9ed8d
7
robot.py
7
robot.py
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue