feat(core): design for T2B1 "unsafe, do not use" screen

[no changelog]
pull/3219/head
tychovrahe 10 months ago committed by TychoVrahe
parent 5a86add884
commit 17f13b4140

@ -48,6 +48,14 @@
#define COLOR_BL_GRAY COLOR_BL_FG
#endif
#ifndef TREZOR_MODEL_R
#define BOOT_WAIT_HEIGHT 25
#define BOOT_WAIT_Y_TOP (DISPLAY_RESY - BOOT_WAIT_HEIGHT)
#else
#define BOOT_WAIT_HEIGHT 12
#define BOOT_WAIT_Y_TOP (DISPLAY_RESY - BOOT_WAIT_HEIGHT)
#endif
// common shared functions
static void format_ver(const char *format, uint32_t version, char *buffer,
@ -79,10 +87,10 @@ void ui_screen_boot(const vendor_header *const vhdr,
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, boot_background);
#ifndef TREZOR_MODEL_R
int image_top = show_string ? 30 : (DISPLAY_RESY - 120) / 2;
// check whether vendor image is 120x120
if (memcmp(vimg, "TOIF\x78\x00\x78\x00", 4) == 0) {
if (memcmp(vimg, "TOIF\x78\x00\x78\x00", 8) == 0) {
uint32_t datalen = *(uint32_t *)(vimg + 8);
display_image((DISPLAY_RESX - 120) / 2, image_top, vimg, datalen + 12);
}
@ -96,6 +104,24 @@ void ui_screen_boot(const vendor_header *const vhdr,
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5 - 25, ver_str, -1,
FONT_NORMAL, COLOR_BL_BG, boot_background);
}
#else
// check whether vendor image is 24x24
if (memcmp(vimg, "TOIG\x18\x00\x18\x00", 8) == 0) {
uint32_t datalen = *(uint32_t *)(vimg + 8);
display_icon((DISPLAY_RESX - 22) / 2, 0, vimg, datalen + 12, COLOR_BL_BG,
boot_background);
}
if (show_string) {
char ver_str[64];
display_text_center(DISPLAY_RESX / 2, 36, vhdr->vstr, vhdr->vstr_len,
FONT_NORMAL, COLOR_BL_BG, boot_background);
format_ver("%d.%d.%d", fw_version, ver_str, sizeof(ver_str));
display_text_center(DISPLAY_RESX / 2, 46, ver_str, -1, FONT_NORMAL,
COLOR_BL_BG, boot_background);
}
#endif
PIXELDATA_DIRTY();
display_refresh();
@ -104,7 +130,8 @@ void ui_screen_boot(const vendor_header *const vhdr,
void ui_screen_boot_wait(int wait_seconds) {
char wait_str[16];
mini_snprintf(wait_str, sizeof(wait_str), "starting in %d s", wait_seconds);
display_bar(0, DISPLAY_RESY - 5 - 20, DISPLAY_RESX, 5 + 20, boot_background);
display_bar(0, BOOT_WAIT_Y_TOP, DISPLAY_RESX, BOOT_WAIT_HEIGHT,
boot_background);
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5, wait_str, -1,
FONT_NORMAL, COLOR_BL_BG, boot_background);
PIXELDATA_DIRTY();
@ -152,10 +179,9 @@ void ui_click(void) {
#endif
void ui_screen_boot_click(void) {
display_bar(0, DISPLAY_RESY - 5 - 20, DISPLAY_RESX, 5 + 20, boot_background);
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 5,
"click to continue ...", -1, FONT_NORMAL, COLOR_BL_BG,
boot_background);
display_bar(0, BOOT_WAIT_Y_TOP, DISPLAY_RESX, BOOT_WAIT_HEIGHT,
boot_background);
bld_continue_label(boot_background);
PIXELDATA_DIRTY();
display_refresh();
ui_click();

@ -28,3 +28,6 @@ void screen_boot_empty(bool fading);
uint32_t screen_unlock_bootloader_confirm(void);
void screen_unlock_bootloader_success(void);
void display_image(int16_t x, int16_t y, const uint8_t* data, uint32_t datalen);
void display_icon(int16_t x, int16_t y, const uint8_t* data, uint32_t datalen,
uint16_t fg_color, uint16_t bg_color);
void bld_continue_label(uint16_t bg_color);

@ -241,6 +241,25 @@ impl<'i> Toif<'i> {
}
}
#[no_mangle]
extern "C" fn display_icon(
x: cty::int16_t,
y: cty::int16_t,
data: *const cty::uint8_t,
data_len: cty::uint32_t,
fg_color: cty::uint16_t,
bg_color: cty::uint16_t,
) {
let data_slice = unsafe { core::slice::from_raw_parts(data, data_len as usize) };
let icon = Icon::new(data_slice);
icon.draw(
Point::new(x, y),
Alignment2D::TOP_LEFT,
Color::from_u16(fg_color),
Color::from_u16(bg_color),
);
}
#[derive(PartialEq, Eq, Clone, Copy)]
pub struct Icon {
pub toif: Toif<'static>,

@ -22,6 +22,12 @@ mod menu;
mod theme;
mod welcome;
use crate::ui::{
constant,
constant::HEIGHT,
geometry::Point,
model_tr::theme::{ICON_ARM_LEFT, ICON_ARM_RIGHT, WHITE},
};
use confirm::Confirm;
use connect::Connect;
use intro::Intro;
@ -366,3 +372,26 @@ extern "C" fn screen_welcome_model() {
let mut frame = WelcomeScreen::new();
show(&mut frame);
}
#[no_mangle]
extern "C" fn bld_continue_label(bg_color: cty::uint16_t) {
display::text_center(
Point::new(constant::WIDTH / 2, HEIGHT - 2),
"CONTINUE",
Font::NORMAL,
WHITE,
Color::from_u16(bg_color),
);
ICON_ARM_LEFT.draw(
Point::new(constant::WIDTH / 2 - 36, HEIGHT - 6),
Alignment2D::TOP_LEFT,
WHITE,
Color::from_u16(bg_color),
);
ICON_ARM_RIGHT.draw(
Point::new(constant::WIDTH / 2 + 25, HEIGHT - 6),
Alignment2D::TOP_LEFT,
WHITE,
Color::from_u16(bg_color),
);
}

@ -417,3 +417,14 @@ extern "C" fn screen_welcome() {
let mut frame = Welcome::new();
show(&mut frame, true);
}
#[no_mangle]
extern "C" fn bld_continue_label(bg_color: cty::uint16_t) {
display::text_center(
Point::new(constant::WIDTH / 2, HEIGHT - 5),
"click to continue ...",
Font::NORMAL,
WHITE,
Color::from_u16(bg_color),
);
}

Loading…
Cancel
Save