Fix display init
This commit is contained in:
parent
daed5c2093
commit
9d4d395a08
1 changed files with 23 additions and 5 deletions
28
src/lib.rs
28
src/lib.rs
|
|
@ -75,7 +75,7 @@ pub struct DoubleFrame<PartialWindow> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The colour of a given pixel.
|
/// The colour of a given pixel.
|
||||||
///
|
///
|
||||||
/// Since the GDEQ031T10 is pure black-and-white (no greyscale), this is just a two-state enum.S
|
/// Since the GDEQ031T10 is pure black-and-white (no greyscale), this is just a two-state enum.S
|
||||||
pub enum PixelColour {
|
pub enum PixelColour {
|
||||||
Black = 0,
|
Black = 0,
|
||||||
|
|
@ -83,7 +83,7 @@ pub enum PixelColour {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A trait for partial window strategies for use with [DoubleFrame].
|
/// A trait for partial window strategies for use with [DoubleFrame].
|
||||||
///
|
///
|
||||||
/// This trait is sealed, so the only strategies available are [NoPartialWindow]
|
/// This trait is sealed, so the only strategies available are [NoPartialWindow]
|
||||||
/// and [AutomaticPartialWindow].
|
/// and [AutomaticPartialWindow].
|
||||||
pub trait ApplyPartialWindow: private::Sealed {
|
pub trait ApplyPartialWindow: private::Sealed {
|
||||||
|
|
@ -100,7 +100,7 @@ pub trait ApplyPartialWindow: private::Sealed {
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Add a new bounding box which must be covered by the partial window.
|
/// Add a new bounding box which must be covered by the partial window.
|
||||||
///
|
///
|
||||||
/// Calls to this method accumulate, meaning all bounding boxes will be covered by the
|
/// Calls to this method accumulate, meaning all bounding boxes will be covered by the
|
||||||
/// partial window until [ApplyPartialWindow::reset_partial_window] is called.
|
/// partial window until [ApplyPartialWindow::reset_partial_window] is called.
|
||||||
fn update_partial_window(&mut self, min_x: u16, max_x: u16, min_y: u16, max_y: u16);
|
fn update_partial_window(&mut self, min_x: u16, max_x: u16, min_y: u16, max_y: u16);
|
||||||
|
|
@ -172,14 +172,14 @@ impl ApplyPartialWindow for AutomaticPartialWindow {
|
||||||
display.write_data((vred & 0xFF) as u8);
|
display.write_data((vred & 0xFF) as u8);
|
||||||
display.write_data(0x00);
|
display.write_data(0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_partial_window(&mut self, min_x: u16, max_x: u16, min_y: u16, max_y: u16) {
|
fn update_partial_window(&mut self, min_x: u16, max_x: u16, min_y: u16, max_y: u16) {
|
||||||
self.min_x = core::cmp::min(self.min_x, min_x);
|
self.min_x = core::cmp::min(self.min_x, min_x);
|
||||||
self.max_x = core::cmp::max(self.max_x, max_x);
|
self.max_x = core::cmp::max(self.max_x, max_x);
|
||||||
self.min_y = core::cmp::min(self.min_y, min_y);
|
self.min_y = core::cmp::min(self.min_y, min_y);
|
||||||
self.max_y = core::cmp::max(self.max_y, max_y);
|
self.max_y = core::cmp::max(self.max_y, max_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reset_partial_window(&mut self) {
|
fn reset_partial_window(&mut self) {
|
||||||
*self = AutomaticPartialWindow {
|
*self = AutomaticPartialWindow {
|
||||||
min_x: EPD_WIDTH as u16,
|
min_x: EPD_WIDTH as u16,
|
||||||
|
|
@ -292,12 +292,30 @@ impl<BusyPin: InputPin, ResetPin: OutputPin, DcPin: OutputPin, Spi: SpiDevice, D
|
||||||
self.reset.set_high().map_err(InitError::ResetError)?;
|
self.reset.set_high().map_err(InitError::ResetError)?;
|
||||||
self.delay.delay_ms(10);
|
self.delay.delay_ms(10);
|
||||||
|
|
||||||
|
self.write_command(0x00).map_err(InitError::WriteError)?;
|
||||||
|
self.write_data(0x1e).map_err(InitError::WriteError)?;
|
||||||
|
self.write_data(0x0d).map_err(InitError::WriteError)?;
|
||||||
|
self.delay.delay_ms(1);
|
||||||
|
|
||||||
self.write_command(0x00).map_err(InitError::WriteError)?;
|
self.write_command(0x00).map_err(InitError::WriteError)?;
|
||||||
self.write_data(0x1f).map_err(InitError::WriteError)?;
|
self.write_data(0x1f).map_err(InitError::WriteError)?;
|
||||||
|
self.write_data(0x0d).map_err(InitError::WriteError)?;
|
||||||
|
self.wait_for_display();
|
||||||
|
|
||||||
|
self.write_command(0xE0).map_err(InitError::WriteError)?;
|
||||||
|
self.write_data(0x02).map_err(InitError::WriteError)?;
|
||||||
|
self.write_command(0xE5).map_err(InitError::WriteError)?;
|
||||||
|
self.write_data(0x5A).map_err(InitError::WriteError)?;
|
||||||
|
self.write_command(0x50).map_err(InitError::WriteError)?;
|
||||||
|
|
||||||
|
self.write_data(0x97).map_err(InitError::WriteError)?;
|
||||||
|
|
||||||
self.write_command(0x04).map_err(InitError::WriteError)?;
|
self.write_command(0x04).map_err(InitError::WriteError)?;
|
||||||
|
|
||||||
self.wait_for_display();
|
self.wait_for_display();
|
||||||
|
|
||||||
|
self.write_command(0x12).map_err(InitError::WriteError)?;
|
||||||
|
self.wait_for_display();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue