1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

trezorctl: fix set_homescreen for python3

This commit is contained in:
Pavol Rusnak 2017-07-16 15:03:01 +02:00
parent d865c0ea31
commit afdd27c551
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

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