1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 21:22:10 +00:00

feat(core): add model name below empty logo on boot

[no changlog]
This commit is contained in:
tychovrahe 2023-08-17 17:01:36 +02:00 committed by matejcik
parent 90bdab6599
commit 5947f8a50d
13 changed files with 53 additions and 57 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@ -1,6 +1,5 @@
use crate::{
strutil::hexlify,
time::Duration,
trezorhal::io::io_button_read,
ui::{
component::{Component, Event, EventCtx, Label, LineBreaking::BreakWordsNoHyphen, Never},
@ -32,7 +31,7 @@ use confirm::Confirm;
use connect::Connect;
use intro::Intro;
use menu::Menu;
use theme::{BLD_BG, BLD_FG, ICON_ALERT, ICON_SPINNER, ICON_SUCCESS, LOGO_EMPTY};
use theme::{BLD_BG, BLD_FG, ICON_ALERT, ICON_SPINNER, ICON_SUCCESS};
use welcome::Welcome;
pub type BootloaderString = String<128>;
@ -322,13 +321,9 @@ extern "C" fn screen_wipe_fail() {
#[no_mangle]
extern "C" fn screen_boot_empty(_fading: bool) {
display::rect_fill(SCREEN, BLD_BG);
LOGO_EMPTY.draw(
SCREEN.top_center() + Offset::y(11),
Alignment2D::TOP_CENTER,
BLD_FG,
BLD_BG,
);
display::refresh();
let mut frame = WelcomeScreen::new(true);
show(&mut frame);
}
#[no_mangle]
@ -366,7 +361,7 @@ extern "C" fn screen_welcome() {
#[no_mangle]
extern "C" fn screen_welcome_model() {
let mut frame = WelcomeScreen::new();
let mut frame = WelcomeScreen::new(false);
show(&mut frame);
}

View File

@ -8,7 +8,6 @@ pub use super::super::theme::{BLACK, WHITE};
pub const BLD_BG: Color = BLACK;
pub const BLD_FG: Color = WHITE;
include_icon!(LOGO_EMPTY, "model_tr/res/logo_22_33_empty.toif");
include_icon!(ICON_TRASH, "model_tr/res/trash.toif");
include_icon!(ICON_ALERT, "model_tr/res/alert.toif");
include_icon!(ICON_SPINNER, "model_tr/res/spinner.toif");

View File

@ -5,15 +5,19 @@ use crate::ui::{
use super::super::theme;
const ICON_TOP_MARGIN: i16 = 11;
const ICON_TOP_MARGIN: i16 = 12;
pub struct WelcomeScreen {
area: Rect,
empty_lock: bool,
}
impl WelcomeScreen {
pub fn new() -> Self {
Self { area: Rect::zero() }
pub fn new(empty_lock: bool) -> Self {
Self {
area: Rect::zero(),
empty_lock,
}
}
}
@ -31,12 +35,17 @@ impl Component for WelcomeScreen {
fn paint(&mut self) {
theme::ICON_DEVICE_NAME.draw(
self.area.bottom_center(),
self.area.bottom_center() - Offset::y(5),
Alignment2D::BOTTOM_CENTER,
theme::FG,
theme::BG,
);
theme::ICON_LOGO.draw(
let icon = if self.empty_lock {
theme::ICON_LOGO_EMPTY
} else {
theme::ICON_LOGO
};
icon.draw(
self.area.top_center() + Offset::y(ICON_TOP_MARGIN),
Alignment2D::TOP_CENTER,
theme::FG,

View File

@ -1422,7 +1422,7 @@ extern "C" fn new_show_lockscreen(n_args: usize, args: *const Obj, kwargs: *mut
extern "C" fn draw_welcome_screen() -> Obj {
// No need of util::try_or_raise, this does not allocate
let mut screen = WelcomeScreen::new();
let mut screen = WelcomeScreen::new(false);
screen.place(constant::screen());
display::sync();
screen.paint();

View File

@ -79,6 +79,7 @@ include_icon!(ICON_DEVICE_NAME, "model_tr/res/device_name.toif"); // 116*18
include_icon!(ICON_EYE, "model_tr/res/eye_round.toif"); // 12*7
include_icon!(ICON_LOCK, "model_tr/res/lock.toif"); // 10*10
include_icon!(ICON_LOGO, "model_tr/res/logo_22_33.toif"); // 22*33
include_icon!(ICON_LOGO_EMPTY, "model_tr/res/logo_22_33_empty.toif");
include_icon!(
ICON_NEXT_PAGE,
"model_tr/res/next_page.toif",

View File

@ -6,7 +6,7 @@ use crate::{
constant::{screen, HEIGHT},
display::{self, Color, Font, Icon},
event::TouchEvent,
geometry::{Alignment2D, Point},
geometry::Point,
model_tt::{
bootloader::{
confirm::ConfirmTitle,
@ -14,13 +14,13 @@ use crate::{
theme::{
button_bld, button_confirm, button_wipe_cancel, button_wipe_confirm, BLD_BG,
BLD_FG, BLD_WIPE_COLOR, CHECK24, CHECK40, DOWNLOAD32, FIRE32, FIRE40,
LOGO_EMPTY, TEXT_WIPE_BOLD, TEXT_WIPE_NORMAL, WARNING40, WELCOME_COLOR, X24,
TEXT_WIPE_BOLD, TEXT_WIPE_NORMAL, WARNING40, WELCOME_COLOR, X24,
},
welcome::Welcome,
},
component::{Button, ResultScreen, WelcomeScreen},
constant,
theme::{BACKLIGHT_DIM, BACKLIGHT_NORMAL, BLACK, FG, WHITE},
theme::{BACKLIGHT_DIM, BACKLIGHT_NORMAL, FG, WHITE},
},
util::{from_c_array, from_c_str},
},
@ -35,6 +35,7 @@ pub mod menu;
pub mod theme;
pub mod welcome;
use crate::ui::model_tt::theme::BLACK;
use confirm::Confirm;
use intro::Intro;
use menu::Menu;
@ -338,17 +339,10 @@ extern "C" fn screen_boot_empty(fading: bool) {
fadeout();
}
let fg = WHITE;
let bg = BLACK;
display::rect_fill(constant::screen(), BLACK);
display::rect_fill(constant::screen(), bg);
let icon = Icon::new(LOGO_EMPTY);
icon.draw(
Point::new(screen().center().x, 48),
Alignment2D::TOP_CENTER,
fg,
bg,
);
let mut frame = WelcomeScreen::new(true);
show(&mut frame, false);
if fading {
fadein();
@ -408,7 +402,7 @@ extern "C" fn screen_install_success(
#[no_mangle]
extern "C" fn screen_welcome_model() {
let mut frame = WelcomeScreen::new();
let mut frame = WelcomeScreen::new(false);
show(&mut frame, false);
}

View File

@ -66,7 +66,6 @@ pub const WARNING40: &[u8] = include_res!("model_tt/res/warning40.toif");
pub const CHECK24: &[u8] = include_res!("model_tt/res/check24.toif");
pub const CHECK40: &[u8] = include_res!("model_tt/res/check40.toif");
pub const LOGO_EMPTY: &[u8] = include_res!("model_tt/res/lock_empty.toif");
pub const DEVICE_NAME: &[u8] = include_res!("model_tt/res/device_name_T.toif");
pub const START_URL: &[u8] = include_res!("model_tt/res/start.toif");

View File

@ -15,11 +15,15 @@ use crate::ui::{constant::MODEL_NAME, display};
pub struct WelcomeScreen {
area: Rect,
empty_lock: bool,
}
impl WelcomeScreen {
pub fn new() -> Self {
Self { area: Rect::zero() }
pub fn new(empty_lock: bool) -> Self {
Self {
area: Rect::zero(),
empty_lock,
}
}
}
@ -36,12 +40,21 @@ impl Component for WelcomeScreen {
}
fn paint(&mut self) {
theme::ICON_LOGO.draw(
self.area.top_center() + Offset::y(ICON_TOP_MARGIN),
Alignment2D::TOP_CENTER,
theme::FG,
theme::BG,
);
if self.empty_lock {
theme::ICON_LOGO_EMPTY.draw(
self.area.top_center() + Offset::y(ICON_TOP_MARGIN),
Alignment2D::TOP_CENTER,
theme::FG,
theme::BG,
);
} else {
theme::ICON_LOGO.draw(
self.area.top_center() + Offset::y(ICON_TOP_MARGIN),
Alignment2D::TOP_CENTER,
theme::FG,
theme::BG,
);
}
#[cfg(not(feature = "bootloader"))]
display::text_center(
self.area.bottom_center() - Offset::y(TEXT_BOTTOM_MARGIN),
@ -52,7 +65,7 @@ impl Component for WelcomeScreen {
);
#[cfg(feature = "bootloader")]
Icon::new(DEVICE_NAME).draw(
self.area.bottom_center() - Offset::y(TEXT_BOTTOM_MARGIN) + Offset::y(1),
self.area.bottom_center() - Offset::y(TEXT_BOTTOM_MARGIN),
Alignment2D::BOTTOM_CENTER,
theme::FG,
theme::BG,

View File

@ -1573,7 +1573,7 @@ extern "C" fn new_show_lockscreen(n_args: usize, args: *const Obj, kwargs: *mut
extern "C" fn draw_welcome_screen() -> Obj {
// No need of util::try_or_raise, this does not allocate
let mut screen = WelcomeScreen::new();
let mut screen = WelcomeScreen::new(false);
screen.place(constant::screen());
display::sync();
screen.paint();

View File

@ -99,6 +99,7 @@ include_icon!(IMAGE_BG_BACK_BTN_TALL, "model_tt/res/bg-back52.toif");
// Welcome screen.
include_icon!(ICON_LOGO, "model_tt/res/lock_full.toif");
include_icon!(ICON_LOGO_EMPTY, "model_tt/res/lock_empty.toif");
// Default homescreen
pub const IMAGE_HOMESCREEN: &[u8] = include_res!("model_tt/res/bg.jpg");

View File

@ -1,13 +1,11 @@
# isort:skip_file
import trezorui2
import utime
# Showing welcome screen as soon as possible
# (display is also prepared on that occasion).
# Remembering time to control how long we show it.
trezorui2.draw_welcome_screen()
welcome_screen_start_ms = utime.ticks_ms()
import storage
import storage.device
@ -21,17 +19,6 @@ from trezor.ui.layouts.homescreen import Lockscreen
from apps.common.request_pin import can_lock_device, verify_user_pin
_WELCOME_SCREEN_MS = 1200 # how long do we want to show welcome screen (minimum)
def enforce_welcome_screen_duration() -> None:
"""Make sure we will show the welcome screen for appropriate amount of time."""
# Not wasting the time in emulator debug builds (debugging and development)
if __debug__ and utils.EMULATOR:
return
while utime.ticks_ms() - welcome_screen_start_ms < _WELCOME_SCREEN_MS:
utime.sleep_ms(100)
async def bootscreen() -> None:
"""Sequence of actions to be done on boot (after device is connected).
@ -47,11 +34,9 @@ async def bootscreen() -> None:
while True:
try:
if can_lock_device():
enforce_welcome_screen_duration()
await lockscreen
await verify_user_pin()
storage.init_unlocked()
enforce_welcome_screen_duration()
allow_all_loader_messages()
return
except wire.PinCancelled: