display views: return error instead of unwrapping
This commit was merged in pull request #49.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
use core::error::Error;
|
||||
use core::fmt::Debug;
|
||||
use core::fmt::Display;
|
||||
use display_interface_spi::SPIInterface;
|
||||
use embedded_graphics::draw_target::DrawTarget;
|
||||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
@@ -6,10 +9,27 @@ use embedded_hal_bus::spi::AtomicDevice;
|
||||
use embedded_hal_bus::util::AtomicCell;
|
||||
use esp_hal::delay::Delay;
|
||||
use esp_hal::gpio::Output;
|
||||
use ili9341::{DisplaySize240x320, Ili9341, Orientation};
|
||||
use ili9341::{DisplayError, DisplaySize240x320, Ili9341, Orientation};
|
||||
|
||||
use crate::drivers::spi_bus::{DisplaySpiBus, SharedOutput};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PrimaryDisplayError(DisplayError);
|
||||
|
||||
impl Display for PrimaryDisplayError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for PrimaryDisplayError {}
|
||||
|
||||
impl From<DisplayError> for PrimaryDisplayError {
|
||||
fn from(value: DisplayError) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
type GenericPrimaryDisplay<'a, BUS, DC, RES> =
|
||||
Ili9341<SPIInterface<AtomicDevice<'a, BUS, Output<'a>, Delay>, DC>, RES>;
|
||||
pub type PrimaryDisplay<'a> =
|
||||
|
||||
Reference in New Issue
Block a user