1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 11:28:14 +00:00

add trezor.utils (pure python)

This commit is contained in:
Pavol Rusnak 2016-04-11 19:39:01 +02:00
parent 4ff68e7494
commit e88cd6f20d
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 6 additions and 1 deletions

View File

@ -3,7 +3,7 @@ from TrezorUi import Display, Touch
display = Display()
touch = Touch()
def rgbcolor(r, g, b):
def rgbcolor(r: int, g: int, b: int) -> int:
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)
RED = rgbcolor(0xF4, 0x43, 0x36)

5
src/trezor/utils.py Normal file
View File

@ -0,0 +1,5 @@
def hexlify(data: bytes) -> str:
return ''.join(['%02x' % b for b in data])
def unhexlify(data: str) -> bytes:
return bytes([int(data[i:i+2], 16) for i in range(0, len(data), 2)])