wacom: group the list2hex output

Group by size 8 by default.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
pull/180/head
Peter Hutterer 2019-08-14 12:32:56 +10:00 committed by Benjamin Tissoires
parent f08100bae2
commit 91203701cf
1 changed files with 8 additions and 2 deletions

View File

@ -108,10 +108,16 @@ def b2hex(bs):
return ' '.join([''.join(s) for s in zip(hx[::2], hx[1::2])])
def list2hex(l):
def list2hex(l, groupsize=8):
'''Converts a list of integers to a two-letter hex string in the form
"1a 2b c3"'''
return ' '.join([f'{x:02x}' for x in l])
slices = []
for idx in range(0, len(l), groupsize):
s = ' '.join([f'{x:02x}' for x in l[idx:idx + groupsize]])
slices.append(s)
return ' '.join(slices)
def list2hexlist(l):