mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-08 23:58:09 +00:00
43 lines
1.3 KiB
Rust
43 lines
1.3 KiB
Rust
#[cfg(feature = "micropython")]
|
|
use crate::micropython::buffer::StrBuffer;
|
|
use crate::ui::{
|
|
component::base::Component, constant::screen, display, model_tr::component::WelcomeScreen,
|
|
};
|
|
|
|
use super::{component::ErrorScreen, constant};
|
|
|
|
#[cfg(not(feature = "micropython"))]
|
|
use crate::strutil::TString;
|
|
#[cfg(not(feature = "micropython"))]
|
|
// SAFETY: Actually safe but see below
|
|
unsafe fn get_str(text: &str) -> TString {
|
|
TString::Str(text)
|
|
}
|
|
#[cfg(feature = "micropython")]
|
|
// SAFETY: The caller is responsible for ensuring that the StrBuffer does not
|
|
// escape the lifetime of the original &str.
|
|
unsafe fn get_str(text: &str) -> StrBuffer {
|
|
unsafe { StrBuffer::from_ptr_and_len(text.as_ptr(), text.len()) }
|
|
}
|
|
|
|
pub fn screen_fatal_error(title: &str, msg: &str, footer: &str) {
|
|
// SAFETY: these will get placed into `frame` which does not outlive this
|
|
// function
|
|
let title = unsafe { get_str(title) };
|
|
let msg = unsafe { get_str(msg) };
|
|
let footer = unsafe { get_str(footer) };
|
|
|
|
let mut frame = ErrorScreen::new(title.into(), msg.into(), footer.into());
|
|
frame.place(constant::screen());
|
|
frame.paint();
|
|
}
|
|
|
|
#[no_mangle]
|
|
extern "C" fn screen_boot_full() {
|
|
let mut frame = WelcomeScreen::new(false);
|
|
frame.place(screen());
|
|
display::sync();
|
|
frame.paint();
|
|
display::refresh();
|
|
}
|