@ -8,7 +8,7 @@
//! - [Controller Datasheet SS1780](http://www.e-paper-display.com/download_detail/downloadsId=682.html)
//!
use crate ::buffer_len ;
use crate ::{ buffer_len } ; use crate ::Error ;
use crate ::color ::Color ;
use crate ::eh_prelude ::* ;
use crate ::interface ::DisplayInterface ;
@ -62,9 +62,9 @@ where
RST : OutputPin ,
DELAY : DelayUs ,
{
fn init ( & mut self , spi : & mut SPI , delay : & mut DELAY ) -> Result < ( ) , SPI ::Error > {
fn init ( & mut self , spi : & mut SPI , delay : & mut DELAY ) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
// HW reset
self . interface . reset ( delay , 10 ) ;
self . interface . reset ( delay , 10 ) ? ;
if self . refresh = = RefreshLut ::Quick {
self . set_vcom_register ( spi , ( - 9 ) . vcom ( ) ) ? ;
@ -164,7 +164,7 @@ where
dc : DC ,
rst : RST ,
delay : & mut DELAY ,
) -> Result < Self , SPI ::Error > {
) -> Result < Self , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
let mut epd = Epd2in13 {
interface : DisplayInterface ::new ( cs , busy , dc , rst ) ,
sleep_mode : DeepSleepMode ::Mode1 ,
@ -176,11 +176,11 @@ where
Ok ( epd )
}
fn wake_up ( & mut self , spi : & mut SPI , delay : & mut DELAY ) -> Result < ( ) , SPI ::Error > {
fn wake_up ( & mut self , spi : & mut SPI , delay : & mut DELAY ) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . init ( spi , delay )
}
fn sleep ( & mut self , spi : & mut SPI , _delay : & mut DELAY ) -> Result < ( ) , SPI ::Error > {
fn sleep ( & mut self , spi : & mut SPI , _delay : & mut DELAY ) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . wait_until_idle ( ) ;
// All sample code enables and disables analog/clocks...
@ -203,7 +203,7 @@ where
spi : & mut SPI ,
buffer : & [ u8 ] ,
_delay : & mut DELAY ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
assert! ( buffer . len ( ) = = buffer_len ( WIDTH as usize , HEIGHT as usize ) ) ;
self . set_ram_area ( spi , 0 , 0 , WIDTH - 1 , HEIGHT - 1 ) ? ;
self . set_ram_address_counters ( spi , 0 , 0 ) ? ;
@ -231,7 +231,7 @@ where
y : u32 ,
width : u32 ,
height : u32 ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
assert! ( ( width * height / 8 ) as usize = = buffer . len ( ) ) ;
// This should not be used when doing partial refresh. The RAM_RED must
@ -260,7 +260,7 @@ where
/// Never use directly this function when using partial refresh, or also
/// keep the base buffer in syncd using `set_partial_base_buffer` function.
fn display_frame ( & mut self , spi : & mut SPI , _delay : & mut DELAY ) -> Result < ( ) , SPI ::Error > {
fn display_frame ( & mut self , spi : & mut SPI , _delay : & mut DELAY ) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
if self . refresh = = RefreshLut ::Full {
self . set_display_update_control_2 (
spi ,
@ -285,7 +285,7 @@ where
spi : & mut SPI ,
buffer : & [ u8 ] ,
delay : & mut DELAY ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . update_frame ( spi , buffer , delay ) ? ;
self . display_frame ( spi , delay ) ? ;
@ -295,7 +295,7 @@ where
Ok ( ( ) )
}
fn clear_frame ( & mut self , spi : & mut SPI , _delay : & mut DELAY ) -> Result < ( ) , SPI ::Error > {
fn clear_frame ( & mut self , spi : & mut SPI , _delay : & mut DELAY ) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
let color = self . background_color . get_byte_value ( ) ;
self . set_ram_area ( spi , 0 , 0 , WIDTH - 1 , HEIGHT - 1 ) ? ;
@ -343,7 +343,7 @@ where
& mut self ,
spi : & mut SPI ,
refresh_rate : Option < RefreshLut > ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
let buffer = match refresh_rate {
Some ( RefreshLut ::Full ) | None = > & LUT_FULL_UPDATE ,
Some ( RefreshLut ::Quick ) = > & LUT_PARTIAL_UPDATE ,
@ -372,7 +372,7 @@ where
& mut self ,
spi : & mut SPI ,
buffer : & [ u8 ] ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
assert! ( buffer_len ( WIDTH as usize , HEIGHT as usize ) = = buffer . len ( ) ) ;
self . set_ram_area ( spi , 0 , 0 , WIDTH - 1 , HEIGHT - 1 ) ? ;
self . set_ram_address_counters ( spi , 0 , 0 ) ? ;
@ -393,7 +393,7 @@ where
spi : & mut SPI ,
delay : & mut DELAY ,
refresh : RefreshLut ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
if self . refresh ! = refresh {
self . refresh = refresh ;
self . init ( spi , delay ) ? ;
@ -405,7 +405,7 @@ where
& mut self ,
spi : & mut SPI ,
start : u16 ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
assert! ( start < = 295 ) ;
self . cmd_with_data (
spi ,
@ -418,7 +418,7 @@ where
& mut self ,
spi : & mut SPI ,
borderwaveform : BorderWaveForm ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . cmd_with_data (
spi ,
Command ::BorderWaveformControl ,
@ -426,7 +426,7 @@ where
)
}
fn set_vcom_register ( & mut self , spi : & mut SPI , vcom : Vcom ) -> Result < ( ) , SPI ::Error > {
fn set_vcom_register ( & mut self , spi : & mut SPI , vcom : Vcom ) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . cmd_with_data ( spi , Command ::WriteVcomRegister , & [ vcom . 0 ] )
}
@ -434,7 +434,7 @@ where
& mut self ,
spi : & mut SPI ,
voltage : GateDrivingVoltage ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . cmd_with_data ( spi , Command ::GateDrivingVoltageCtrl , & [ voltage . 0 ] )
}
@ -442,12 +442,12 @@ where
& mut self ,
spi : & mut SPI ,
number_of_lines : u8 ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
assert! ( number_of_lines < = 127 ) ;
self . cmd_with_data ( spi , Command ::SetDummyLinePeriod , & [ number_of_lines ] )
}
fn set_gate_line_width ( & mut self , spi : & mut SPI , width : u8 ) -> Result < ( ) , SPI ::Error > {
fn set_gate_line_width ( & mut self , spi : & mut SPI , width : u8 ) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . cmd_with_data ( spi , Command ::SetGateLineWidth , & [ width & 0x0F ] )
}
@ -458,7 +458,7 @@ where
vsh1 : SourceDrivingVoltage ,
vsh2 : SourceDrivingVoltage ,
vsl : SourceDrivingVoltage ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . cmd_with_data (
spi ,
Command ::SourceDrivingVoltageCtrl ,
@ -472,16 +472,16 @@ where
& mut self ,
spi : & mut SPI ,
value : DisplayUpdateControl2 ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . cmd_with_data ( spi , Command ::DisplayUpdateControl2 , & [ value . 0 ] )
}
/// Triggers the deep sleep mode
fn set_sleep_mode ( & mut self , spi : & mut SPI , mode : DeepSleepMode ) -> Result < ( ) , SPI ::Error > {
fn set_sleep_mode ( & mut self , spi : & mut SPI , mode : DeepSleepMode ) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . cmd_with_data ( spi , Command ::DeepSleepMode , & [ mode as u8 ] )
}
fn set_driver_output ( & mut self , spi : & mut SPI , output : DriverOutput ) -> Result < ( ) , SPI ::Error > {
fn set_driver_output ( & mut self , spi : & mut SPI , output : DriverOutput ) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . cmd_with_data ( spi , Command ::DriverOutputControl , & output . to_bytes ( ) )
}
@ -492,7 +492,7 @@ where
spi : & mut SPI ,
counter_incr_mode : DataEntryModeIncr ,
counter_direction : DataEntryModeDir ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
let mode = counter_incr_mode as u8 | counter_direction as u8 ;
self . cmd_with_data ( spi , Command ::DataEntryModeSetting , & [ mode ] )
}
@ -505,7 +505,7 @@ where
start_y : u32 ,
end_x : u32 ,
end_y : u32 ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . cmd_with_data (
spi ,
Command ::SetRamXAddressStartEndPosition ,
@ -530,7 +530,7 @@ where
spi : & mut SPI ,
x : u32 ,
y : u32 ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . wait_until_idle ( ) ;
self . cmd_with_data ( spi , Command ::SetRamXAddressCounter , & [ ( x > > 3 ) as u8 ] ) ? ;
@ -542,7 +542,7 @@ where
Ok ( ( ) )
}
fn command ( & mut self , spi : & mut SPI , command : Command ) -> Result < ( ) , SPI ::Error > {
fn command ( & mut self , spi : & mut SPI , command : Command ) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . interface . cmd ( spi , command )
}
@ -551,7 +551,7 @@ where
spi : & mut SPI ,
command : Command ,
data : & [ u8 ] ,
) -> Result < ( ) , SPI ::Error > {
) -> Result < ( ) , Error < SPI ::Error , CS ::Error , BUSY ::Error , DC ::Error , RST ::Error , DELAY ::Error > > {
self . interface . cmd_with_data ( spi , command , data )
}