1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-19 12:58:13 +00:00

refactor color and font definitions to trezor.ui module

This commit is contained in:
Pavol Rusnak 2016-04-01 00:44:59 +02:00
parent dc20152afe
commit 37a33efc57
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
4 changed files with 39 additions and 43 deletions

View File

@ -1,39 +1,10 @@
from trezor import ui
def rgb2color(r, g, b):
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)
RED = rgb2color(0xF4, 0x43, 0x36)
PINK = rgb2color(0xE9, 0x1E, 0x63)
PURPLE = rgb2color(0x9C, 0x27, 0xB0)
DEEP_PURPLE = rgb2color(0x67, 0x3A, 0xB7)
INDIGO = rgb2color(0x3F, 0x51, 0xB5)
BLUE = rgb2color(0x21, 0x96, 0xF3)
LIGHT_BLUE = rgb2color(0x03, 0xA9, 0xF4)
CYAN = rgb2color(0x00, 0xBC, 0xD4)
TEAL = rgb2color(0x00, 0x96, 0x88)
GREEN = rgb2color(0x4C, 0xAF, 0x50)
LIGHT_GREEN = rgb2color(0x8B, 0xC3, 0x4A)
LIME = rgb2color(0xCD, 0xDC, 0x39)
YELLOW = rgb2color(0xFF, 0xEB, 0x3B)
AMBER = rgb2color(0xFF, 0xC1, 0x07)
ORANGE = rgb2color(0xFF, 0x98, 0x00)
DEEP_ORANGE = rgb2color(0xFF, 0x57, 0x22)
BROWN = rgb2color(0x79, 0x55, 0x48)
GREY = rgb2color(0x9E, 0x9E, 0x9E)
BLUE_GRAY = rgb2color(0x60, 0x7D, 0x8B)
BLACK = rgb2color(0x00, 0x00, 0x00)
WHITE = rgb2color(0xFF, 0xFF, 0xFF)
MONO = 0
NORMAL = 1
BOLD = 2
def show_send(address, amount, currency='BTC'):
ui.display.bar(0, 0, 240, 40, GREEN)
ui.display.bar(0, 40, 240, 200, WHITE)
ui.display.text(10, 28, 'Sending', BOLD, WHITE, GREEN)
ui.display.text(10, 80, '%f %s' % (amount, currency), BOLD, BLACK, WHITE)
ui.display.text(10, 110, 'to this address:', NORMAL, BLACK, WHITE)
ui.display.text(10, 140, address[:18], MONO, BLACK, WHITE)
ui.display.text(10, 160, address[18:], MONO, BLACK, WHITE)
ui.display.bar(0, 0, 240, 40, ui.GREEN)
ui.display.bar(0, 40, 240, 200, ui.WHITE)
ui.display.text(10, 28, 'Sending', ui.BOLD, ui.WHITE, ui.GREEN)
ui.display.text(10, 80, '%f %s' % (amount, currency), ui.BOLD, ui.BLACK, ui.WHITE)
ui.display.text(10, 110, 'to this address:', ui.NORMAL, ui.BLACK, ui.WHITE)
ui.display.text(10, 140, address[:18], ui.MONO, ui.BLACK, ui.WHITE)
ui.display.text(10, 160, address[18:], ui.MONO, ui.BLACK, ui.WHITE)

View File

@ -9,8 +9,6 @@ import gc
from uasyncio import core
from trezor import ui
from .import utils
logging.basicConfig(level=logging.INFO)
loop = core.get_event_loop()
@ -28,7 +26,7 @@ def animate():
col %= 0xff
col += 0x0f
ui.display.icon(190, 170, f.read(), utils.rgb2color(col, 0, 0), 0xffff)
ui.display.icon(190, 170, f.read(), ui.rgbcolor(col, 0, 0), 0xffff)
f.seek(0)
yield from core.sleep(0.5)
@ -64,7 +62,7 @@ def tap_to_confirm():
MIN_COLOR = 0x00
MAX_COLOR = 0xB0
_background = utils.rgb2color(255, 255, 255)
_background = ui.rgbcolor(255, 255, 255)
x = math.pi
while True:
x += STEP_X
@ -74,7 +72,7 @@ def tap_to_confirm():
# Normalize color from interval 0:2 to MIN_COLOR:MAX_COLOR
col = int((MAX_COLOR - MIN_COLOR) / 2 * y) + MIN_COLOR
foreground = utils.rgb2color(BASE_COLOR[0] + col, BASE_COLOR[1] + col, BASE_COLOR[2] + col)
foreground = ui.rgbcolor(BASE_COLOR[0] + col, BASE_COLOR[1] + col, BASE_COLOR[2] + col)
ui.display.text(10, 220, 'TAP TO CONFIRM', 2, foreground, _background)

View File

@ -1,2 +0,0 @@
def rgb2color(r, g, b):
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)

View File

@ -2,3 +2,32 @@ from TrezorUi import Display, Touch
display = Display()
touch = Touch()
def rgbcolor(r, g, b):
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)
RED = rgbcolor(0xF4, 0x43, 0x36)
PINK = rgbcolor(0xE9, 0x1E, 0x63)
PURPLE = rgbcolor(0x9C, 0x27, 0xB0)
DEEP_PURPLE = rgbcolor(0x67, 0x3A, 0xB7)
INDIGO = rgbcolor(0x3F, 0x51, 0xB5)
BLUE = rgbcolor(0x21, 0x96, 0xF3)
LIGHT_BLUE = rgbcolor(0x03, 0xA9, 0xF4)
CYAN = rgbcolor(0x00, 0xBC, 0xD4)
TEAL = rgbcolor(0x00, 0x96, 0x88)
GREEN = rgbcolor(0x4C, 0xAF, 0x50)
LIGHT_GREEN = rgbcolor(0x8B, 0xC3, 0x4A)
LIME = rgbcolor(0xCD, 0xDC, 0x39)
YELLOW = rgbcolor(0xFF, 0xEB, 0x3B)
AMBER = rgbcolor(0xFF, 0xC1, 0x07)
ORANGE = rgbcolor(0xFF, 0x98, 0x00)
DEEP_ORANGE = rgbcolor(0xFF, 0x57, 0x22)
BROWN = rgbcolor(0x79, 0x55, 0x48)
GREY = rgbcolor(0x9E, 0x9E, 0x9E)
BLUE_GRAY = rgbcolor(0x60, 0x7D, 0x8B)
BLACK = rgbcolor(0x00, 0x00, 0x00)
WHITE = rgbcolor(0xFF, 0xFF, 0xFF)
MONO = 0
NORMAL = 1
BOLD = 2