display views: return error instead of unwrapping
This commit was merged in pull request #49.
This commit is contained in:
+12
-9
@@ -1,4 +1,5 @@
|
||||
use crate::display::sprite::render_sprite_onto_ili9341;
|
||||
use crate::drivers::primary_lcd::PrimaryDisplayError;
|
||||
use crate::navigation::navigation::NewState;
|
||||
use crate::navigation::outputs::Outputs;
|
||||
use crate::peripherals::Peripherals;
|
||||
@@ -35,7 +36,9 @@ impl Navigable for CardView {
|
||||
) -> impl core::future::Future<Output = Result<(), Box<dyn error::Error>>> + Send {
|
||||
async move {
|
||||
let display = &mut outputs.primary_display;
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
display
|
||||
.clear(Rgb565::BLACK)
|
||||
.map_err(PrimaryDisplayError::from)?;
|
||||
|
||||
let background = Rectangle::new(Point::new(0, 0), Size::new(240, 320));
|
||||
let bg_color = self.card.cardtype.clone().into();
|
||||
@@ -49,56 +52,56 @@ impl Navigable for CardView {
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
.map_err(PrimaryDisplayError::from)?;
|
||||
Text::new(
|
||||
&format!("Type: {}", self.card.cardtype),
|
||||
Point::new(20, 250),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
.map_err(PrimaryDisplayError::from)?;
|
||||
Text::new(
|
||||
&format!("Event: {}", self.card.event),
|
||||
Point::new(20, 260),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
.map_err(PrimaryDisplayError::from)?;
|
||||
Text::new(
|
||||
&format!("UUID: {}", self.card.uuid),
|
||||
Point::new(20, 270),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
.map_err(PrimaryDisplayError::from)?;
|
||||
Text::new(
|
||||
&format!("Trait1: {}", self.card.trait1),
|
||||
Point::new(20, 280),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
.map_err(PrimaryDisplayError::from)?;
|
||||
Text::new(
|
||||
&format!("Trait2: {}", self.card.trait2),
|
||||
Point::new(20, 290),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
.map_err(PrimaryDisplayError::from)?;
|
||||
Text::new(
|
||||
&format!("Trait3: {}", self.card.trait3),
|
||||
Point::new(20, 300),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
.map_err(PrimaryDisplayError::from)?;
|
||||
Text::new(
|
||||
&format!("Secret: {}", self.card.secret),
|
||||
Point::new(20, 310),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
.map_err(PrimaryDisplayError::from)?;
|
||||
|
||||
let palette: Palette = self.card.cardtype.clone().into();
|
||||
render_sprite_onto_ili9341(display, self.card.sprite.data.as_slice(), &palette);
|
||||
|
||||
Reference in New Issue
Block a user