|
|
|
@ -12,6 +12,7 @@ use drawing::color::Color;
|
|
|
|
|
|
|
|
|
|
/// Interface for the physical connection between display and the controlling device
|
|
|
|
|
pub mod connection_interface;
|
|
|
|
|
use self::connection_interface::ConnectionInterface;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// All commands need to have this trait which gives the address of the command
|
|
|
|
@ -21,6 +22,12 @@ pub(crate) trait Command {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub trait Displays {
|
|
|
|
|
fn width(self) -> u8;
|
|
|
|
|
fn height(self) -> u8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: add LUT trait with set_fast_lut and set_manual_lut and set_normal_lut or sth like that?
|
|
|
|
|
// for partial updates
|
|
|
|
|
trait LUTSupport<Error> {
|
|
|
|
@ -30,14 +37,14 @@ trait LUTSupport<Error> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub trait WaveshareInterface<SPI, CS, BUSY, DC, RST, D, E>
|
|
|
|
|
pub trait WaveshareInterface<SPI, CS, BUSY, DataCommand, RST, Delay, Error>
|
|
|
|
|
where
|
|
|
|
|
SPI: Write<u8, Error = E>,
|
|
|
|
|
SPI: Write<u8>,
|
|
|
|
|
CS: OutputPin,
|
|
|
|
|
BUSY: InputPin,
|
|
|
|
|
DC: OutputPin,
|
|
|
|
|
DataCommand: OutputPin,
|
|
|
|
|
RST: OutputPin,
|
|
|
|
|
D: DelayUs<u16> + DelayMs<u16>,
|
|
|
|
|
Delay: DelayUs<u16> + DelayMs<u16>,
|
|
|
|
|
{
|
|
|
|
|
/// Get the width of the display
|
|
|
|
|
fn get_width(&self) -> u16;
|
|
|
|
@ -49,13 +56,8 @@ pub trait WaveshareInterface<SPI, CS, BUSY, DC, RST, D, E>
|
|
|
|
|
///
|
|
|
|
|
/// This already initialises the device. That means [init()](WaveshareInterface::init()) isn't needed directly afterwards
|
|
|
|
|
fn new(
|
|
|
|
|
spi: SPI,
|
|
|
|
|
cs: CS,
|
|
|
|
|
busy: BUSY,
|
|
|
|
|
dc: DC,
|
|
|
|
|
rst: RST,
|
|
|
|
|
delay: D
|
|
|
|
|
) -> Result<Self, E>
|
|
|
|
|
interface: ConnectionInterface<SPI, CS, BUSY, DataCommand, RST, Delay>,
|
|
|
|
|
) -> Result<Self, Error>
|
|
|
|
|
where Self: Sized;
|
|
|
|
|
|
|
|
|
|
/// This initialises the EPD and powers it up
|
|
|
|
@ -65,13 +67,13 @@ pub trait WaveshareInterface<SPI, CS, BUSY, DC, RST, D, E>
|
|
|
|
|
/// This function calls [reset()](WaveshareInterface::reset()),
|
|
|
|
|
/// so you don't need to call reset your self when trying to wake your device up
|
|
|
|
|
/// after setting it to sleep.
|
|
|
|
|
fn init(&mut self) -> Result<(), E>;
|
|
|
|
|
fn init(&mut self) -> Result<(), Error>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// void DisplayFrame(const unsigned char* frame_buffer);
|
|
|
|
|
/// Transmit a full frame to the SRAM of the DPD
|
|
|
|
|
///
|
|
|
|
|
fn update_frame(&mut self, buffer: &[u8]) -> Result<(), E>;
|
|
|
|
|
fn update_frame(&mut self, buffer: &[u8]) -> Result<(), Error>;
|
|
|
|
|
|
|
|
|
|
//TODO: is dtm always used?
|
|
|
|
|
/// Transmit partial data to the SRAM of the EPD,
|
|
|
|
@ -81,18 +83,18 @@ pub trait WaveshareInterface<SPI, CS, BUSY, DC, RST, D, E>
|
|
|
|
|
/// Normally it should be dtm2, so use false
|
|
|
|
|
///
|
|
|
|
|
/// BUFFER needs to be of size: w / 8 * l !
|
|
|
|
|
fn update_partial_frame(&mut self, buffer: &[u8], x: u16, y: u16, width: u16, height: u16) -> Result<(), E>;
|
|
|
|
|
fn update_partial_frame(&mut self, buffer: &[u8], x: u16, y: u16, width: u16, height: u16) -> Result<(), Error>;
|
|
|
|
|
|
|
|
|
|
/// Displays the frame data from SRAM
|
|
|
|
|
fn display_frame(&mut self) -> Result<(), E>;
|
|
|
|
|
fn display_frame(&mut self) -> Result<(), Error>;
|
|
|
|
|
|
|
|
|
|
// TODO: add this abstraction function
|
|
|
|
|
fn update_and_display_frame(&mut self, buffer: &[u8]) -> Result<(), E>;
|
|
|
|
|
fn update_and_display_frame(&mut self, buffer: &[u8]) -> Result<(), Error>;
|
|
|
|
|
|
|
|
|
|
/// Clears the frame from the buffer
|
|
|
|
|
///
|
|
|
|
|
/// Uses the chosen background color
|
|
|
|
|
fn clear_frame(&mut self) -> Result<(), E>;
|
|
|
|
|
fn clear_frame(&mut self) -> Result<(), Error>;
|
|
|
|
|
|
|
|
|
|
/// Sets the backgroundcolor for various commands like [clear_frame()](WaveshareInterface::clear_frame())
|
|
|
|
|
fn set_background_color(&mut self, color: Color);
|
|
|
|
@ -104,7 +106,7 @@ pub trait WaveshareInterface<SPI, CS, BUSY, DC, RST, D, E>
|
|
|
|
|
/// But you can also use [reset()](WaveshareInterface::reset()) to awaken.
|
|
|
|
|
/// But as you need to power it up once more anyway you can also just directly use [init()](WaveshareInterface::init()) for resetting
|
|
|
|
|
/// and initialising which already contains the reset
|
|
|
|
|
fn sleep(&mut self) -> Result<(), E>;
|
|
|
|
|
fn sleep(&mut self) -> Result<(), Error>;
|
|
|
|
|
|
|
|
|
|
/// Resets the device.
|
|
|
|
|
///
|
|
|
|
|