|
|
|
@ -23,12 +23,29 @@ use super::{
|
|
|
|
|
FIRE40, RESULT_FW_INSTALL, RESULT_INITIAL, RESULT_WIPE, TEXT_BOLD, TEXT_NORMAL,
|
|
|
|
|
TEXT_WIPE_BOLD, TEXT_WIPE_NORMAL, WARNING40, WELCOME_COLOR, X24,
|
|
|
|
|
},
|
|
|
|
|
BACKLIGHT_NORMAL, BLACK, FG, WHITE,
|
|
|
|
|
BACKLIGHT_NORMAL, BLACK, FG,
|
|
|
|
|
},
|
|
|
|
|
ModelTTFeatures,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
use crate::ui::{ui_features::UIFeaturesBootloader, UIFeaturesCommon};
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "new_rendering")]
|
|
|
|
|
use crate::ui::{
|
|
|
|
|
constant,
|
|
|
|
|
display::toif::Toif,
|
|
|
|
|
geometry::{Alignment, Alignment2D, Offset},
|
|
|
|
|
shape,
|
|
|
|
|
shape::render_on_display,
|
|
|
|
|
util::version_split,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "new_rendering")]
|
|
|
|
|
use ufmt::uwrite;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "new_rendering")]
|
|
|
|
|
use super::theme::bootloader::BLD_WARN_COLOR;
|
|
|
|
|
|
|
|
|
|
use intro::Intro;
|
|
|
|
|
use menu::Menu;
|
|
|
|
|
|
|
|
|
@ -43,6 +60,7 @@ const RECONNECT_MESSAGE: &str = "PLEASE RECONNECT\nTHE DEVICE";
|
|
|
|
|
const SCREEN: Rect = ModelTTFeatures::SCREEN;
|
|
|
|
|
|
|
|
|
|
impl ModelTTFeatures {
|
|
|
|
|
#[cfg(not(feature = "new_rendering"))]
|
|
|
|
|
fn screen_progress(
|
|
|
|
|
text: &str,
|
|
|
|
|
progress: u16,
|
|
|
|
@ -70,6 +88,60 @@ impl ModelTTFeatures {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "new_rendering")]
|
|
|
|
|
fn screen_progress(
|
|
|
|
|
text: &str,
|
|
|
|
|
progress: u16,
|
|
|
|
|
initialize: bool,
|
|
|
|
|
fg_color: Color,
|
|
|
|
|
bg_color: Color,
|
|
|
|
|
icon: Option<(Icon, Color)>,
|
|
|
|
|
) {
|
|
|
|
|
if initialize {
|
|
|
|
|
ModelTTFeatures::fadeout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render_on_display(None, Some(bg_color), |target| {
|
|
|
|
|
shape::Text::new(Point::new(SCREEN.width() / 2, SCREEN.height() - 45), text)
|
|
|
|
|
.with_align(Alignment::Center)
|
|
|
|
|
.with_font(Font::NORMAL)
|
|
|
|
|
.with_fg(fg_color)
|
|
|
|
|
.render(target);
|
|
|
|
|
|
|
|
|
|
let center = SCREEN.center() + Offset::y(-20);
|
|
|
|
|
|
|
|
|
|
let inactive_color = bg_color.blend(fg_color, 85);
|
|
|
|
|
|
|
|
|
|
shape::Circle::new(center, constant::LOADER_OUTER)
|
|
|
|
|
.with_bg(inactive_color)
|
|
|
|
|
.render(target);
|
|
|
|
|
|
|
|
|
|
shape::Circle::new(center, constant::LOADER_OUTER)
|
|
|
|
|
.with_bg(fg_color)
|
|
|
|
|
.with_end_angle(((progress as i32 * shape::PI4 as i32 * 8) / 1000) as i16)
|
|
|
|
|
.render(target);
|
|
|
|
|
|
|
|
|
|
shape::Circle::new(center, constant::LOADER_INNER + 2)
|
|
|
|
|
.with_bg(fg_color)
|
|
|
|
|
.render(target);
|
|
|
|
|
|
|
|
|
|
shape::Circle::new(center, constant::LOADER_INNER)
|
|
|
|
|
.with_bg(bg_color)
|
|
|
|
|
.render(target);
|
|
|
|
|
|
|
|
|
|
if let Some((icon, color)) = icon {
|
|
|
|
|
shape::ToifImage::new(center, icon.toif)
|
|
|
|
|
.with_align(Alignment2D::CENTER)
|
|
|
|
|
.with_fg(color)
|
|
|
|
|
.render(target);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if initialize {
|
|
|
|
|
ModelTTFeatures::fadein();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn screen_install_success_bld(msg: &str, complete_draw: bool) {
|
|
|
|
|
let mut frame = ResultScreen::new(
|
|
|
|
|
&RESULT_FW_INSTALL,
|
|
|
|
@ -104,7 +176,7 @@ impl UIFeaturesBootloader for ModelTTFeatures {
|
|
|
|
|
Point::new(SCREEN.width() / 2, SCREEN.height() - 5),
|
|
|
|
|
"click to continue ...",
|
|
|
|
|
Font::NORMAL,
|
|
|
|
|
WHITE,
|
|
|
|
|
BLD_FG,
|
|
|
|
|
bg_color,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -250,6 +322,7 @@ impl UIFeaturesBootloader for ModelTTFeatures {
|
|
|
|
|
ModelTTFeatures::fadeout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "new_rendering"))]
|
|
|
|
|
display::rect_fill(SCREEN, BLACK);
|
|
|
|
|
|
|
|
|
|
let mut frame = WelcomeScreen::new(true);
|
|
|
|
@ -317,4 +390,87 @@ impl UIFeaturesBootloader for ModelTTFeatures {
|
|
|
|
|
);
|
|
|
|
|
show(&mut frame, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "new_rendering")]
|
|
|
|
|
fn screen_boot(
|
|
|
|
|
warning: bool,
|
|
|
|
|
vendor_str: Option<&str>,
|
|
|
|
|
version: u32,
|
|
|
|
|
vendor_img: &[u8],
|
|
|
|
|
wait: i32,
|
|
|
|
|
) {
|
|
|
|
|
let bg_color = if warning { BLD_WARN_COLOR } else { BLD_BG };
|
|
|
|
|
|
|
|
|
|
render_on_display(None, Some(bg_color), |target| {
|
|
|
|
|
// Draw vendor image if it's valid and has size of 120x120
|
|
|
|
|
if let Ok(toif) = Toif::new(vendor_img) {
|
|
|
|
|
if (toif.width() == 120) && (toif.height() == 120) {
|
|
|
|
|
// Image position depends on the vendor string presence
|
|
|
|
|
let pos = if vendor_str.is_some() {
|
|
|
|
|
Point::new(SCREEN.width() / 2, 30)
|
|
|
|
|
} else {
|
|
|
|
|
Point::new(SCREEN.width() / 2, 60)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
shape::ToifImage::new(pos, toif)
|
|
|
|
|
.with_align(Alignment2D::TOP_CENTER)
|
|
|
|
|
.with_fg(BLD_FG)
|
|
|
|
|
.render(target);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Draw vendor string if present
|
|
|
|
|
if let Some(text) = vendor_str {
|
|
|
|
|
let pos = Point::new(SCREEN.width() / 2, SCREEN.height() - 5 - 50);
|
|
|
|
|
shape::Text::new(pos, text)
|
|
|
|
|
.with_align(Alignment::Center)
|
|
|
|
|
.with_font(Font::NORMAL)
|
|
|
|
|
.with_fg(BLD_FG) //COLOR_BL_BG
|
|
|
|
|
.render(target);
|
|
|
|
|
|
|
|
|
|
let pos = Point::new(SCREEN.width() / 2, SCREEN.height() - 5 - 25);
|
|
|
|
|
|
|
|
|
|
let mut version_text: BootloaderString = String::new();
|
|
|
|
|
let ver_nums = version_split(version);
|
|
|
|
|
unwrap!(uwrite!(
|
|
|
|
|
version_text,
|
|
|
|
|
"{}.{}.{}",
|
|
|
|
|
ver_nums[0],
|
|
|
|
|
ver_nums[1],
|
|
|
|
|
ver_nums[2]
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
shape::Text::new(pos, version_text.as_str())
|
|
|
|
|
.with_align(Alignment::Center)
|
|
|
|
|
.with_font(Font::NORMAL)
|
|
|
|
|
.with_fg(BLD_FG)
|
|
|
|
|
.render(target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Draw a message
|
|
|
|
|
match wait.cmp(&0) {
|
|
|
|
|
core::cmp::Ordering::Equal => {}
|
|
|
|
|
core::cmp::Ordering::Greater => {
|
|
|
|
|
let mut text: BootloaderString = String::new();
|
|
|
|
|
unwrap!(uwrite!(text, "starting in {} s", wait));
|
|
|
|
|
|
|
|
|
|
let pos = Point::new(SCREEN.width() / 2, SCREEN.height() - 5);
|
|
|
|
|
shape::Text::new(pos, text.as_str())
|
|
|
|
|
.with_align(Alignment::Center)
|
|
|
|
|
.with_font(Font::NORMAL)
|
|
|
|
|
.with_fg(BLD_FG)
|
|
|
|
|
.render(target);
|
|
|
|
|
}
|
|
|
|
|
core::cmp::Ordering::Less => {
|
|
|
|
|
let pos = Point::new(SCREEN.width() / 2, SCREEN.height() - 5);
|
|
|
|
|
shape::Text::new(pos, "click to continue ...")
|
|
|
|
|
.with_align(Alignment::Center)
|
|
|
|
|
.with_font(Font::NORMAL)
|
|
|
|
|
.with_fg(BLD_FG)
|
|
|
|
|
.render(target);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|