trezorctl: fix set_homescreen for python3
This commit is contained in:
parent
d865c0ea31
commit
afdd27c551
10
trezorctl
10
trezorctl
|
@ -194,13 +194,15 @@ def set_homescreen(client, filename):
|
||||||
raise CallException(types.Failure_DataError, 'Wrong size of the image')
|
raise CallException(types.Failure_DataError, 'Wrong size of the image')
|
||||||
im = im.convert('1')
|
im = im.convert('1')
|
||||||
pix = im.load()
|
pix = im.load()
|
||||||
img = ''
|
img = bytearray(1024)
|
||||||
for j in range(64):
|
for j in range(64):
|
||||||
for i in range(128):
|
for i in range(128):
|
||||||
img += '1' if pix[i, j] else '0'
|
if pix[i, j]:
|
||||||
img = ''.join(chr(int(img[i:i + 8], 2)) for i in range(0, len(img), 8))
|
o = (i + j * 128)
|
||||||
|
img[o // 8] |= (1 << (7 - o % 8))
|
||||||
|
img = bytes(img)
|
||||||
else:
|
else:
|
||||||
img = '\x00'
|
img = b'\x00'
|
||||||
return client.apply_settings(homescreen=img)
|
return client.apply_settings(homescreen=img)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue