From fd9e6c7132a5020b19e716df6625c5fd306ce0b7 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Wed, 11 Jan 2023 14:40:27 +0100 Subject: [PATCH] DO NOT MERGE: ping shows colors, no text over homescreen --- .../src/ui/model_tt/component/homescreen/mod.rs | 13 ++++--------- .../src/ui/model_tt/component/homescreen/render.rs | 2 +- core/src/apps/base.py | 14 ++++++++++---- core/src/boot.py | 4 ++-- core/src/storage/device.py | 2 +- core/src/trezor/ui/layouts/tt/__init__.py | 12 +++++++++--- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/core/embed/rust/src/ui/model_tt/component/homescreen/mod.rs b/core/embed/rust/src/ui/model_tt/component/homescreen/mod.rs index ed188815e..4d08cecf4 100644 --- a/core/embed/rust/src/ui/model_tt/component/homescreen/mod.rs +++ b/core/embed/rust/src/ui/model_tt/component/homescreen/mod.rs @@ -202,7 +202,7 @@ impl Component for Homescreen { label_style.text_color = theme::FG; let text = HomescreenText { - text: self.label, + text: "".into(), style: label_style, offset: Offset::y(LABEL_Y), icon: None, @@ -221,7 +221,7 @@ impl Component for Homescreen { homescreen( &mut hs_img, &[text], - notification, + None, self.paint_notification_only, ); show_default = false; @@ -233,7 +233,7 @@ impl Component for Homescreen { homescreen( &mut hs_img, &[text], - notification, + None, self.paint_notification_only, ); show_default = false; @@ -244,12 +244,7 @@ impl Component for Homescreen { let mut input = BufferInput(IMAGE_HOMESCREEN); let mut pool = BufferJpegWork::get_cleared(); let mut hs_img = HomescreenJpeg::new(&mut input, pool.buffer.as_mut_slice()); - homescreen( - &mut hs_img, - &[text], - notification, - self.paint_notification_only, - ); + homescreen(&mut hs_img, &[text], None, self.paint_notification_only); } } } diff --git a/core/embed/rust/src/ui/model_tt/component/homescreen/render.rs b/core/embed/rust/src/ui/model_tt/component/homescreen/render.rs index 458f5aa35..854a0d26e 100644 --- a/core/embed/rust/src/ui/model_tt/component/homescreen/render.rs +++ b/core/embed/rust/src/ui/model_tt/component/homescreen/render.rs @@ -354,7 +354,7 @@ fn homescreen_line( for x in 0..HOMESCREEN_IMAGE_WIDTH { let d = image_data[x as usize]; - let c = if homescreen_dim_area(x, y) { + let c = if false { let coef = (65536_f32 * HOMESCREEN_DIM) as u32; let r = (d & 0xF800) >> 8; diff --git a/core/src/apps/base.py b/core/src/apps/base.py index 4ba716ce4..d2c0e7eb1 100644 --- a/core/src/apps/base.py +++ b/core/src/apps/base.py @@ -237,12 +237,18 @@ async def handle_EndSession(msg: EndSession) -> Success: return Success() +def rgb(r: int, g: int, b: int) -> int: + return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3) + + async def handle_Ping(msg: Ping) -> Success: - if msg.button_protection: - from trezor.enums import ButtonRequestType as B - from trezor.ui.layouts import confirm_action + from trezor.ui.layouts import confirm_action + + c = msg.message + color = rgb(int(c[0:2], 16), int(c[2:4], 16), int(c[4:6], 16)) + print(f"color: {color}") - await confirm_action("ping", TR.words__confirm, "ping", br_code=B.ProtectCall) + await confirm_action("ping", "Confirm", "ping", color=color) return Success(message=msg.message) diff --git a/core/src/boot.py b/core/src/boot.py index be33be964..ed325cad6 100644 --- a/core/src/boot.py +++ b/core/src/boot.py @@ -86,8 +86,8 @@ ignore_nonpin_loader_messages() config.init(show_pin_timeout) translations.init() -if __debug__ and not utils.EMULATOR: - config.wipe() +# if __debug__ and not utils.EMULATOR: +# config.wipe() loop.schedule(bootscreen()) loop.run() diff --git a/core/src/storage/device.py b/core/src/storage/device.py index cf6ba0e92..7c8d89de8 100644 --- a/core/src/storage/device.py +++ b/core/src/storage/device.py @@ -43,7 +43,7 @@ if TYPE_CHECKING: StorageSafetyCheckLevel = Literal[0, 1] # fmt: on -HOMESCREEN_MAXSIZE = const(16384) +HOMESCREEN_MAXSIZE = const(163840) LABEL_MAXLENGTH = const(32) if __debug__: diff --git a/core/src/trezor/ui/layouts/tt/__init__.py b/core/src/trezor/ui/layouts/tt/__init__.py index 919f9a962..6ed1f89bf 100644 --- a/core/src/trezor/ui/layouts/tt/__init__.py +++ b/core/src/trezor/ui/layouts/tt/__init__.py @@ -39,10 +39,11 @@ class RustLayout(LayoutParentType[T]): BACKLIGHT_LEVEL = ui.style.BACKLIGHT_NORMAL # pylint: disable=super-init-not-called - def __init__(self, layout: trezorui2.LayoutObj[T]): + def __init__(self, layout: trezorui2.LayoutObj[T], color: int | None = None): self.layout = layout self.timer = loop.Timer() self.layout.attach_timer_fn(self.set_timer) + self.color = color def set_timer(self, token: int, deadline: int) -> None: self.timer.schedule(deadline, token) @@ -55,8 +56,11 @@ class RustLayout(LayoutParentType[T]): import storage.cache as storage_cache painted = self.layout.paint() - + if self.color is not None: + print("PAINTING") + ui.display.bar(0, 0, ui.WIDTH, ui.HEIGHT - 60, self.color) ui.refresh() + if storage_cache.homescreen_shown is not None and painted: storage_cache.homescreen_shown = None @@ -255,6 +259,7 @@ def confirm_action( reverse: bool = False, exc: ExceptionType = ActionCancelled, br_code: ButtonRequestType = BR_TYPE_OTHER, + color: int | None = None, ) -> Awaitable[None]: if verb is not None: verb = verb.upper() @@ -276,7 +281,8 @@ def confirm_action( hold=hold, hold_danger=hold_danger, reverse=reverse, - ) + ), + color=color, ), br_type, br_code,