fixup! feat(core/rust): homescreen background

tychovrahe/homescreen/bg
Martin Milata 2 years ago committed by tychovrahe
parent c3f6bf1a55
commit 27e591db47

@ -16,11 +16,9 @@ use crate::{
use render::{
homescreen, homescreen_blurred, HomescreenNotification, HomescreenText, HOMESCREEN_IMAGE_SIZE,
HOMESCREEN_MAX_TEXTS,
};
use crate::{trezorhal::display::ToifFormat, ui::display::toif_info};
use heapless::Vec;
use super::{theme, Loader, LoaderMsg};
@ -188,13 +186,12 @@ where
let mut label_style = theme::TEXT_BOLD;
label_style.text_color = theme::FG;
let texts: Vec<HomescreenText, HOMESCREEN_MAX_TEXTS> =
unwrap!(Vec::from_slice(&[HomescreenText {
text: self.label.as_ref(),
style: label_style,
offset: Offset::new(10, LABEL_Y),
icon: None
}],));
let text = HomescreenText {
text: self.label.as_ref(),
style: label_style,
offset: Offset::new(10, LABEL_Y),
icon: None,
};
let notification = self.get_notification();
@ -202,14 +199,14 @@ where
if let Ok(data) = res {
homescreen(
data.as_ref(),
texts,
&[text],
notification,
self.paint_notification_only,
);
} else {
homescreen(
IMAGE_HOMESCREEN,
texts,
&[text],
notification,
self.paint_notification_only,
);
@ -273,32 +270,32 @@ where
let mut label_style = theme::TEXT_BOLD;
label_style.text_color = theme::GREY_MEDIUM;
let texts: Vec<HomescreenText, HOMESCREEN_MAX_TEXTS> = unwrap!(Vec::from_slice(&[
let texts: [HomescreenText; 3] = [
HomescreenText {
text: locked,
style: theme::TEXT_BOLD,
offset: Offset::new(10, LOCKED_Y),
icon: Some(theme::ICON_LOCK)
icon: Some(theme::ICON_LOCK),
},
HomescreenText {
text: tap,
style: tap_style,
offset: Offset::new(10, TAP_Y),
icon: None
icon: None,
},
HomescreenText {
text: self.label.as_ref(),
style: label_style,
offset: Offset::new(10, LABEL_Y),
icon: None
icon: None,
},
],));
];
let res = get_image();
if let Ok(data) = res {
homescreen_blurred(data.as_ref(), texts);
homescreen_blurred(data.as_ref(), &texts);
} else {
homescreen_blurred(IMAGE_HOMESCREEN, texts);
homescreen_blurred(IMAGE_HOMESCREEN, &texts);
}
}
}

@ -15,7 +15,6 @@ use crate::{
geometry::{Offset, Point, Rect},
},
};
use heapless::Vec;
use crate::ui::{
component::text::TextStyle,
@ -47,7 +46,6 @@ struct HomescreenTextInfo {
pub icon_area: Option<Rect>,
}
pub const HOMESCREEN_MAX_TEXTS: usize = 4;
pub const HOMESCREEN_IMAGE_SIZE: i16 = 120;
const HOMESCREEN_MAX_ICON_SIZE: i16 = 20;
@ -271,7 +269,7 @@ fn homescreen_line(
}
fn homescreen_next_text(
texts: &Vec<HomescreenText, HOMESCREEN_MAX_TEXTS>,
texts: &[HomescreenText],
text_buffer: &mut BufferText,
icon_data: &mut [u8],
text_info: HomescreenTextInfo,
@ -380,7 +378,7 @@ fn vertical_avg(
}
}
pub fn homescreen_blurred(data: &[u8], texts: Vec<HomescreenText, HOMESCREEN_MAX_TEXTS>) {
pub fn homescreen_blurred(data: &[u8], texts: &[HomescreenText]) {
let mut icon_data = [0_u8; (HOMESCREEN_MAX_ICON_SIZE * HOMESCREEN_MAX_ICON_SIZE / 2) as usize];
let text_buffer = unsafe { get_text_buffer(0, true) };
@ -501,7 +499,7 @@ pub fn homescreen_blurred(data: &[u8], texts: Vec<HomescreenText, HOMESCREEN_MAX
pub fn homescreen(
data: &[u8],
texts: Vec<HomescreenText, HOMESCREEN_MAX_TEXTS>,
texts: &[HomescreenText],
notification: Option<HomescreenNotification>,
notification_only: bool,
) {

Loading…
Cancel
Save