feat(ui): setup homescreen and label for model R

[no changelog]
pull/2280/head
grdddj 2 years ago committed by Jiří Musil
parent c5f1bec474
commit 6dc4426151

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@ -52,8 +52,19 @@ class Homescreen(HomescreenBase):
ui.display.bar(0, 0, ui.WIDTH, ui.HEIGHT, ui.BG)
# homescreen with shifted avatar and text on bottom
ui.display.avatar(48, 48 - 10, self.get_image(), ui.WHITE, ui.BLACK)
label_heights = {"1": 54, "R": 110, "T": 220}
# Differs for each model
# TODO: support homescreen avatar change for R and 1
if utils.MODEL in ("T",):
ui.display.avatar(48, 48 - 10, self.get_image(), ui.WHITE, ui.BLACK)
elif utils.MODEL in ("R",):
icon = "trezor/res/homescreen_model_r.toif" # 92x92 px
ui.display.icon(18, 18, ui.res.load(icon), ui.style.FG, ui.style.BG)
elif utils.MODEL in ("1",):
icon = "trezor/res/homescreen_model_1.toif" # 64x36 px
ui.display.icon(33, 14, ui.res.load(icon), ui.style.FG, ui.style.BG)
label_heights = {"1": 60, "R": 120, "T": 220}
ui.display.text_center(
ui.WIDTH // 2, label_heights[utils.MODEL], self.label, ui.BOLD, ui.FG, ui.BG
)

@ -1,4 +1,5 @@
# generated from resources.py.mako
# (by running `make templates` in `core`)
# do not edit manually!
# fmt: off
@ -27,6 +28,10 @@ def load_resource(name: str) -> bytes:
return b'TOIg\x18\x00\x18\x00\x97\x00\x00\x00E\xcf\xb1\r\xc20\x10\x85a\xdb(\x82\x08!\xb9\xa5\xa3\xa2\x85\r`\x03\xd8\x00\xc4\x04\x8c\xc0\x06\x88\x92\x8al\xc0\nl\x106\xc8\x08i@ @\xfe\xb1\x9dK\xfc\x1a\x7f\xb6N\xe7;\xa5B\x8cJ9\'\xe6\xef\xe4Kr\x9fo\xe7\x15L\x84\xba\x82B<\x00\x9e\xe2\x99w[t\x0c\xbe5\xae\x82_\x91\xbd@\\t\x16\xcd\xb2\xf9\tW\xc3^Z>\x16p\x90\xf7"\x17\xfb\xfa\xb9\x91\x1a\x83\xb3\xaaf\x1d\x1b\x95X]\xfb{\xc8\x86m\x86l0\xe4>jg\xd0\xe5\xe7\xfa\xb32\xe8\x18N\xddb\xd3]<\xfe'
if name == "trezor/res/header_icons/wrong.toif":
return b"TOIg\x18\x00\x18\x00\xaa\x00\x00\x00c`\xc0\x05\xaa\x1c@$\xcbr !v~3\x88\xad\xf56\x91\x81\xa1\xf7\xff/\x05\x06\x06\xa6\xf5\xffo00\xec\xff\xff\x7f\x11P\xf8\xff\xff\xdf\x0c\x0c\xd1@R\x01(\xfc\x7f+\x03\x033Pb\x02'P\xc0\x80\x01,\xfdr\xde\xff\xff`\x13\x98\x80\x12Pa\x06\x06\xab\xf7\xff\xff\xff[\x0c\xb1\x8cq\xfe\xff\xff\xbf\x04\xa06\x03\xd9?\xa1LM\x90\x9aI\x10%\xebAzA\x96\x83\xcd\xfc\xb5\x0el9\xc8%\xff\x17JA$\xbc@f\x83,_\xc2\xc0\xb0\x1el\xa56\xd8m\xbd`+\x81\x96\xdf\x04\xfa\xe5>\xd8%\xd6\x7f\x0b\x81Fv\x07\x80\xd8\xac;\x04p\x86\x02\x00"
if name == "trezor/res/homescreen_model_1.toif":
return b'TOIg@\x00$\x00\x8d\x01\x00\x00\xdd\x92\xbfO\xc2@\x14\xc7\xdb\xf8\x0f@\xe1\x1fh\xe5\x0f\x90\x1f\t3\x90:8W4q\xb5\xc0n\xa4\xc8j\x84`t\x96\x808\x99\x10\x82qs\xa0i\x9c\xd5Zw\x93\xf6\x9c\x05\xdb\xfe\x03Z\xbc\xde\xb5G\xaf&NN~\xa7{\xfd\xbc\xf7\xed{w\x8fa\xb08\xb11\xd0\x80\x03e\xeb\x93\x8e\xc43\xb4R\x8d\xa9\xe1,\x039\xa6\xda\xc9R8\xd3^Q\x9c1.Gp\xba\xfd\xb2\x8c\xe9c\\"\x98\xdd\xc5\xd8\xb3\x9f\xa1\x80\x8b\x13N\x12\xa4\xfc\x12}\xb2\x9f\xfa\xcdZ\xad\xde\xbb\x01(\xf9\x91\x18\x14Q\xb97\xdbG]s\x9bC\x94\xfey\x1c\xdao\xbd\xf9\xf1\xe2 0d\x8b\xf7~\xfcu\x1d\xc6{(\x7fN\xfc\xd2W\xc8\xef\xce\xe7\x9c \x08\x98\xbf\x97\x85@\x99\x11\xe6\xf0\xc8\xd7\x14E9C|\xd1U\x02\xb5\x90\xbf\xf7\x00\x8fM\xcd\xb2,\x80\xa7\xb3\x88\xf0\x846<\xe9`\xf9\xab\xec\xbf\xe1\xe8bi\x81(\x7f\x95\xb7\xe3\x1aQ<\x9b\x8c)E\xf3\x8d\xd8\xbe0k\xe7\xff\x8a\x97\xe2<M\xcd?oJ\xb9\xe4\n&\xd7\xc5\xfam\x94{\xa6z!W\x04\xb4p,W\xa8\x1eM\r\x97~?\xcf6g])\xcfsy\xb154\x80\x1b\xbe\x9f\xe1\x92\xb7t,}\xd2m\r4\xcb!\x9f<\xb3\xa7\x19\x91\xd01\r\'R`\xea\xfdB\xd5\xafp\x7fn\x86gC7\xb9\x027\x1c\xb5\x03\\\x1a\x9aj_\xae\xf0\xc1<\\a\xe7T#\xce\xf0/\xfa\xe4\x90@$V\x10\x1b\xb83\xbf\xcb\x8e\x94K\xc4/\xcc\x1f\x1bN\x06\xa7\x0c/\x02\xe9\x1b'
if name == "trezor/res/homescreen_model_r.toif":
return b'TOIg\\\x00\\\x00O\x02\x00\x00\xed\x92?LSA\x1c\xc7\xaf\xf8Zqk\xc0h\xdc\xc0\xea\x80\x13\xd00(K5\xb1\x94\xb8\xb4\xa9\t5q\xd0\x84\x81A\x07\x87\x0e5,&\xe0@\x05\x8c\xe1\xdfP\x06\xff$\x92\x88:\xc0`\x8c\xca\xa2\x91\x87\xafu3\x82\r\x1d5\xb1\xe5\xcdP\xde\xfd\xb4\xd0{\xbd{w\xf7\xdecS\xf2>\xdb\xfd\xee\x93_~w\xdf\x1fB\x16Z/\x0f\xbdx\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8\xec\xdd\x12\xb8\xc2x\x9e\xac\x85\x15\x9dw#\xaf\x0fv\xee\xbf\xfeL\xca\xb1\xbd1s\xc9\xfcX_\xcf\x03\x87\xc6I&d\xdf\xb5\x82\xdc-O\xb7[\xd7G\xc9I\xc6\xc1kq\xd1n\x9e\xcf\x0b>\x13\x17\x9fI\xd6^\x10\xc9\xdf\xa0\x90\x94\x18\x1b7\xfe1\x1dD6\xf8\xc7\xa8\xd7V\x16\x12\xc8\x81\x81\x1ci\xaf\x8e"g\x94\xcc^\xfb\xdd\xd9\x04r\x83/\x9a\xd5A\x1d\x0c"\x97\x84RT\xd04\x7f\x00'
if name == "trezor/res/left.toif":
return b'TOIg\x10\x00\x10\x00=\x00\x00\x00c``\xe0X\xc0\x00\x06\xf9\xbf\x05@\x14\xdb\xff\xff`:\xff\xffC\x08\xf7\x0fD\xf6\xffcFAAA\xa0\xec\xbf\xff\xff\xff\xff\xad\xff\x0f\x06\xff`4L\x1c\xa6\x0e\xae\x0ff\x0e\xdc\\\x98=\x10{\x01'
if name == "trezor/res/lock.toif":

@ -143,18 +143,31 @@ def header(
display.text(44, 35, title, BOLD, fg, bg)
# Common for both header functions
MODEL_HEADER_HEIGHTS = {"1": 12, "R": 15, "T": 30}
MODEL_Y_BASELINES = {"1": 10, "R": 11, "T": 22}
def header_warning(message: str, clear: bool = True) -> None:
display.bar(0, 0, WIDTH, 30, style.YELLOW)
display.text_center(WIDTH // 2, 22, message, BOLD, style.BLACK, style.YELLOW)
height = MODEL_HEADER_HEIGHTS[utils.MODEL]
y_baseline = MODEL_Y_BASELINES[utils.MODEL]
display.bar(0, 0, WIDTH, height, style.YELLOW)
display.text_center(
WIDTH // 2, y_baseline, message, BOLD, style.BLACK, style.YELLOW
)
if clear:
display.bar(0, 30, WIDTH, HEIGHT - 30, style.BG)
display.bar(0, height, WIDTH, HEIGHT - height, style.BG)
def header_error(message: str, clear: bool = True) -> None:
display.bar(0, 0, WIDTH, 30, style.RED)
display.text_center(WIDTH // 2, 22, message, BOLD, style.WHITE, style.RED)
height = MODEL_HEADER_HEIGHTS[utils.MODEL]
y_baseline = MODEL_Y_BASELINES[utils.MODEL]
display.bar(0, 0, WIDTH, height, style.RED)
display.text_center(WIDTH // 2, y_baseline, message, BOLD, style.WHITE, style.RED)
if clear:
display.bar(0, 30, WIDTH, HEIGHT - 30, style.BG)
display.bar(0, height, WIDTH, HEIGHT - height, style.BG)
def draw_simple(t: "Component") -> None:

@ -153,6 +153,9 @@ def from_image(
blend = Image.alpha_composite(img_background, image)
image = blend.convert("RGB")
if image.mode == "1":
image = image.convert("L")
if image.mode == "L":
toif_mode = firmware.ToifMode.grayscale
if image.size[0] % 2 != 0:

Loading…
Cancel
Save