fixup! feat(core/rust): homescreen background

mmilata/homescreen/bg
Martin Milata 2 years ago
parent d21c44d73f
commit 2541c83dfc

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

@ -15,7 +15,6 @@ use crate::{
geometry::{Offset, Point, Rect}, geometry::{Offset, Point, Rect},
}, },
}; };
use heapless::Vec;
use crate::ui::{ use crate::ui::{
component::text::TextStyle, component::text::TextStyle,
@ -47,7 +46,6 @@ struct HomescreenTextInfo {
pub icon_area: Option<Rect>, pub icon_area: Option<Rect>,
} }
pub const HOMESCREEN_MAX_TEXTS: usize = 4;
pub const HOMESCREEN_IMAGE_SIZE: i16 = 120; pub const HOMESCREEN_IMAGE_SIZE: i16 = 120;
const HOMESCREEN_MAX_ICON_SIZE: i16 = 20; const HOMESCREEN_MAX_ICON_SIZE: i16 = 20;
@ -271,7 +269,7 @@ fn homescreen_line(
} }
fn homescreen_next_text( fn homescreen_next_text(
texts: &Vec<HomescreenText, HOMESCREEN_MAX_TEXTS>, texts: &[HomescreenText],
text_buffer: &mut BufferText, text_buffer: &mut BufferText,
icon_data: &mut [u8], icon_data: &mut [u8],
text_info: HomescreenTextInfo, 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 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) }; 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( pub fn homescreen(
data: &[u8], data: &[u8],
texts: Vec<HomescreenText, HOMESCREEN_MAX_TEXTS>, texts: &[HomescreenText],
notification: Option<HomescreenNotification>, notification: Option<HomescreenNotification>,
notification_only: bool, notification_only: bool,
) { ) {

Loading…
Cancel
Save