DO NOT MERGE: ping shows colors, no text over homescreen

mmilata/color
Martin Milata 1 year ago
parent 2db05b747b
commit fd9e6c7132

@ -202,7 +202,7 @@ impl Component for Homescreen {
label_style.text_color = theme::FG; label_style.text_color = theme::FG;
let text = HomescreenText { let text = HomescreenText {
text: self.label, text: "".into(),
style: label_style, style: label_style,
offset: Offset::y(LABEL_Y), offset: Offset::y(LABEL_Y),
icon: None, icon: None,
@ -221,7 +221,7 @@ impl Component for Homescreen {
homescreen( homescreen(
&mut hs_img, &mut hs_img,
&[text], &[text],
notification, None,
self.paint_notification_only, self.paint_notification_only,
); );
show_default = false; show_default = false;
@ -233,7 +233,7 @@ impl Component for Homescreen {
homescreen( homescreen(
&mut hs_img, &mut hs_img,
&[text], &[text],
notification, None,
self.paint_notification_only, self.paint_notification_only,
); );
show_default = false; show_default = false;
@ -244,12 +244,7 @@ impl Component for Homescreen {
let mut input = BufferInput(IMAGE_HOMESCREEN); let mut input = BufferInput(IMAGE_HOMESCREEN);
let mut pool = BufferJpegWork::get_cleared(); let mut pool = BufferJpegWork::get_cleared();
let mut hs_img = HomescreenJpeg::new(&mut input, pool.buffer.as_mut_slice()); let mut hs_img = HomescreenJpeg::new(&mut input, pool.buffer.as_mut_slice());
homescreen( homescreen(&mut hs_img, &[text], None, self.paint_notification_only);
&mut hs_img,
&[text],
notification,
self.paint_notification_only,
);
} }
} }
} }

@ -354,7 +354,7 @@ fn homescreen_line(
for x in 0..HOMESCREEN_IMAGE_WIDTH { for x in 0..HOMESCREEN_IMAGE_WIDTH {
let d = image_data[x as usize]; 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 coef = (65536_f32 * HOMESCREEN_DIM) as u32;
let r = (d & 0xF800) >> 8; let r = (d & 0xF800) >> 8;

@ -237,12 +237,18 @@ async def handle_EndSession(msg: EndSession) -> Success:
return 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: async def handle_Ping(msg: Ping) -> Success:
if msg.button_protection: from trezor.ui.layouts import confirm_action
from trezor.enums import ButtonRequestType as B
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) return Success(message=msg.message)

@ -86,8 +86,8 @@ ignore_nonpin_loader_messages()
config.init(show_pin_timeout) config.init(show_pin_timeout)
translations.init() translations.init()
if __debug__ and not utils.EMULATOR: # if __debug__ and not utils.EMULATOR:
config.wipe() # config.wipe()
loop.schedule(bootscreen()) loop.schedule(bootscreen())
loop.run() loop.run()

@ -43,7 +43,7 @@ if TYPE_CHECKING:
StorageSafetyCheckLevel = Literal[0, 1] StorageSafetyCheckLevel = Literal[0, 1]
# fmt: on # fmt: on
HOMESCREEN_MAXSIZE = const(16384) HOMESCREEN_MAXSIZE = const(163840)
LABEL_MAXLENGTH = const(32) LABEL_MAXLENGTH = const(32)
if __debug__: if __debug__:

@ -39,10 +39,11 @@ class RustLayout(LayoutParentType[T]):
BACKLIGHT_LEVEL = ui.style.BACKLIGHT_NORMAL BACKLIGHT_LEVEL = ui.style.BACKLIGHT_NORMAL
# pylint: disable=super-init-not-called # 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.layout = layout
self.timer = loop.Timer() self.timer = loop.Timer()
self.layout.attach_timer_fn(self.set_timer) self.layout.attach_timer_fn(self.set_timer)
self.color = color
def set_timer(self, token: int, deadline: int) -> None: def set_timer(self, token: int, deadline: int) -> None:
self.timer.schedule(deadline, token) self.timer.schedule(deadline, token)
@ -55,8 +56,11 @@ class RustLayout(LayoutParentType[T]):
import storage.cache as storage_cache import storage.cache as storage_cache
painted = self.layout.paint() 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() ui.refresh()
if storage_cache.homescreen_shown is not None and painted: if storage_cache.homescreen_shown is not None and painted:
storage_cache.homescreen_shown = None storage_cache.homescreen_shown = None
@ -255,6 +259,7 @@ def confirm_action(
reverse: bool = False, reverse: bool = False,
exc: ExceptionType = ActionCancelled, exc: ExceptionType = ActionCancelled,
br_code: ButtonRequestType = BR_TYPE_OTHER, br_code: ButtonRequestType = BR_TYPE_OTHER,
color: int | None = None,
) -> Awaitable[None]: ) -> Awaitable[None]:
if verb is not None: if verb is not None:
verb = verb.upper() verb = verb.upper()
@ -276,7 +281,8 @@ def confirm_action(
hold=hold, hold=hold,
hold_danger=hold_danger, hold_danger=hold_danger,
reverse=reverse, reverse=reverse,
) ),
color=color,
), ),
br_type, br_type,
br_code, br_code,

Loading…
Cancel
Save