Improve documentation
parent
598a6924ea
commit
f039b1f6a4
|
|
@ -29,8 +29,7 @@ use eink_waveshare_rs::{
|
||||||
epd1in54::EPD1in54,
|
epd1in54::EPD1in54,
|
||||||
SPI_MODE,
|
SPI_MODE,
|
||||||
//drawing_old::{Graphics},
|
//drawing_old::{Graphics},
|
||||||
color::Color,
|
prelude::*,
|
||||||
WaveshareDisplay,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
10
src/color.rs
10
src/color.rs
|
|
@ -1,13 +1,17 @@
|
||||||
|
//! B/W Color for EPDs
|
||||||
|
|
||||||
|
|
||||||
|
/// Only for the Black/White-Displays
|
||||||
/// Only for the B/W Displays atm
|
|
||||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
|
/// Black color
|
||||||
Black,
|
Black,
|
||||||
|
/// White color
|
||||||
White,
|
White,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Rename get_bit_value to bit() and get_byte_value to byte() ?
|
||||||
|
|
||||||
impl Color {
|
impl Color {
|
||||||
/// Get the color encoding of the color for one bit
|
/// Get the color encoding of the color for one bit
|
||||||
pub fn get_bit_value(&self) -> u8 {
|
pub fn get_bit_value(&self) -> u8 {
|
||||||
|
|
@ -25,7 +29,7 @@ impl Color {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses
|
/// Parses from u8 to Color
|
||||||
fn from_u8(val: u8) -> Self {
|
fn from_u8(val: u8) -> Self {
|
||||||
match val {
|
match val {
|
||||||
0 => Color::Black,
|
0 => Color::Black,
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! Graphics Support for EPDs
|
||||||
|
|
||||||
use color::Color;
|
use color::Color;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
|
|
||||||
|
|
|
||||||
13
src/lib.rs
13
src/lib.rs
|
|
@ -48,7 +48,6 @@ extern crate embedded_graphics;
|
||||||
pub mod graphics;
|
pub mod graphics;
|
||||||
|
|
||||||
mod traits;
|
mod traits;
|
||||||
pub use traits::{WaveshareDisplay};
|
|
||||||
|
|
||||||
pub mod color;
|
pub mod color;
|
||||||
|
|
||||||
|
|
@ -67,10 +66,18 @@ pub mod epd2in9;
|
||||||
#[cfg(any(feature = "epd1in54", feature = "epd2in9"))]
|
#[cfg(any(feature = "epd1in54", feature = "epd2in9"))]
|
||||||
pub(crate) mod type_a;
|
pub(crate) mod type_a;
|
||||||
|
|
||||||
/// SPI mode -
|
pub mod prelude {
|
||||||
/// For more infos see [Requirements: SPI](index.html#spi)
|
pub use traits::{WaveshareDisplay};
|
||||||
|
pub use color::Color;
|
||||||
|
pub use SPI_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extern crate embedded_hal as hal;
|
extern crate embedded_hal as hal;
|
||||||
use hal::spi::{Mode, Phase, Polarity};
|
use hal::spi::{Mode, Phase, Polarity};
|
||||||
|
|
||||||
|
/// SPI mode -
|
||||||
|
/// For more infos see [Requirements: SPI](index.html#spi)
|
||||||
pub const SPI_MODE: Mode = Mode {
|
pub const SPI_MODE: Mode = Mode {
|
||||||
phase: Phase::CaptureOnFirstTransition,
|
phase: Phase::CaptureOnFirstTransition,
|
||||||
polarity: Polarity::IdleLow,
|
polarity: Polarity::IdleLow,
|
||||||
|
|
|
||||||
|
|
@ -3,20 +3,15 @@ use hal::{
|
||||||
blocking::{delay::*, spi::Write},
|
blocking::{delay::*, spi::Write},
|
||||||
digital::*,
|
digital::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use color::Color;
|
use color::Color;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// All commands need to have this trait which gives the address of the command
|
/// All commands need to have this trait which gives the address of the command
|
||||||
/// which needs to be send via SPI with activated CommandsPin (Data/Command Pin in CommandMode)
|
/// which needs to be send via SPI with activated CommandsPin (Data/Command Pin in CommandMode)
|
||||||
pub(crate) trait Command {
|
pub(crate) trait Command {
|
||||||
fn address(self) -> u8;
|
fn address(self) -> u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Trait for using various Waveforms from different LUTs
|
// Trait for using various Waveforms from different LUTs
|
||||||
// E.g. for partial updates
|
// E.g. for partial updates
|
||||||
trait LUTSupport<ERR> {
|
trait LUTSupport<ERR> {
|
||||||
|
|
@ -25,7 +20,6 @@ trait LUTSupport<ERR> {
|
||||||
fn set_lut_manual(&mut self, data: &[u8]) -> Result<(), ERR>;
|
fn set_lut_manual(&mut self, data: &[u8]) -> Result<(), ERR>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub(crate) trait InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
pub(crate) trait InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
|
|
@ -48,6 +42,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// All the functions to interact with the EPDs
|
||||||
|
///
|
||||||
|
/// This trait includes all public functions to use the EPDS
|
||||||
pub trait WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
pub trait WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
|
|
@ -73,6 +70,7 @@ where
|
||||||
/// and initialising which already contains the reset
|
/// and initialising which already contains the reset
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error>;
|
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error>;
|
||||||
|
|
||||||
|
/// Wakes the device up from sleep
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>;
|
fn wake_up<DELAY: DelayMs<u8>>(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue