Wrote more doc comments

This commit is contained in:
Zac Wilson 2025-12-18 11:50:41 +00:00
parent 32edbb8ce4
commit 6e96359b44

View file

@ -64,12 +64,20 @@ pub struct DoubleFrame<PartialWindow> {
partial_window: PartialWindow,
}
/// The colour of a given pixel.
///
/// Since the GDEQ031T10 is pure black-and-white (no greyscale), this is just a two-state enum.S
pub enum PixelColour {
Black = 0,
White = 1,
}
/// A trait for partial window strategies for use with [DoubleFrame].
///
/// This trait is sealed, so the only strategies available are [NoPartialWindow]
/// and [AutomaticPartialWindow].
pub trait ApplyPartialWindow: private::Sealed {
/// Applies the given window to the display so that its next update will only refresh part of the display.
fn apply<
BusyPin: InputPin,
ResetPin: OutputPin,
@ -81,8 +89,13 @@ pub trait ApplyPartialWindow: private::Sealed {
display: &mut EPaperDisplay<BusyPin, ResetPin, DcPin, Spi, Delay>,
);
/// 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
/// 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);
/// Resets the partial window to be empty.
fn reset_partial_window(&mut self);
}
@ -94,6 +107,8 @@ mod private {
impl Sealed for super::AutomaticPartialWindow {}
}
/// A partial window strategy which doesn't do any window tracking and simply updates
/// the entire display.
pub struct NoPartialWindow;
impl ApplyPartialWindow for NoPartialWindow {
@ -114,6 +129,8 @@ impl ApplyPartialWindow for NoPartialWindow {
fn reset_partial_window(&mut self) {}
}
/// A partial window strategy which tracks the bounding box of all changes made to the display
/// since the last display update and only updates that region.
pub struct AutomaticPartialWindow {
min_x: u16,
max_x: u16,
@ -301,10 +318,12 @@ impl<BusyPin: InputPin, ResetPin: OutputPin, DcPin: OutputPin, Spi: SpiDevice, D
self.write_data(0xA5);
}
/// Enables partial updates based on whichever strategy was chosen at time of display initialisation.
pub fn enable_partial_mode(&mut self) {
self.write_command(0x91);
}
/// Disable partial updates; all updates will refresh the entire display.
pub fn disable_partial_mode(&mut self) {
self.write_command(0x92);
}