improved documenation
parent
cfe9126fe7
commit
634598c111
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
|
||||
/// Only for the B/W Displays atm
|
||||
pub enum Color {
|
||||
Black,
|
||||
White
|
||||
}
|
||||
|
||||
impl Color {
|
||||
/// Get the color encoding of the color for one bit
|
||||
pub fn get_bit_value(&self) -> u8 {
|
||||
match self {
|
||||
Color::White => 1u8,
|
||||
|
|
@ -13,6 +13,7 @@ impl Color {
|
|||
}
|
||||
}
|
||||
|
||||
/// Gets a full byte of black or white pixels
|
||||
pub fn get_byte_value(&self) -> u8 {
|
||||
match self {
|
||||
Color::White => 0xff,
|
||||
|
|
@ -20,8 +21,13 @@ impl Color {
|
|||
}
|
||||
}
|
||||
|
||||
//position counted from the left (highest value) from 0 to 7
|
||||
//remember: 1 is white, 0 is black
|
||||
|
||||
/// Get the color encoding of a specific bit in a byte
|
||||
///
|
||||
/// input is the byte where one bit is gonna be selected
|
||||
/// pos is counted from the left (highest value) from 0 to 7
|
||||
/// remember: 1 is white, 0 is black
|
||||
/// Color is the color you want to draw with in the foreground
|
||||
pub(crate) fn get_color(input: u8, pos: u8, color: &Color) -> Color {
|
||||
match Color::is_drawable_pixel(input, pos) {
|
||||
true => Color::normal_color(color),
|
||||
|
|
@ -29,6 +35,7 @@ impl Color {
|
|||
}
|
||||
}
|
||||
|
||||
// Inverses the given color from Black to White or from White to Black
|
||||
fn inverse_color(color: &Color) -> Color {
|
||||
match color {
|
||||
Color::White => Color::Black,
|
||||
|
|
@ -36,7 +43,8 @@ impl Color {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Gives you a new owned copy of the color
|
||||
//TODO: just use clone?
|
||||
fn normal_color(color: &Color) -> Color {
|
||||
match color {
|
||||
Color::White => Color::White,
|
||||
|
|
@ -50,7 +58,7 @@ impl Color {
|
|||
((input >> (7 - pos)) & 1u8) > 0u8
|
||||
}
|
||||
|
||||
|
||||
//TODO: does basically the same as get_color, so remove one of them?
|
||||
pub(crate) fn convert_color(input: u8, pos: u8, foreground_color: &Color) -> Color {
|
||||
//match color:
|
||||
// - white for "nothing to draw"/background drawing
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use hal::{
|
|||
|
||||
use interface::Command;
|
||||
|
||||
/// EPD4in2 driver
|
||||
/// The Connection Interface of all (?) Waveshare EPD-Devices
|
||||
///
|
||||
pub(crate) struct ConnectionInterface<SPI, CS, BUSY, DC, RST, D> {
|
||||
/// SPI
|
||||
|
|
|
|||
|
|
@ -3,34 +3,27 @@ use hal::{
|
|||
spi::Write,
|
||||
delay::*
|
||||
},
|
||||
spi::{Mode, Phase, Polarity},
|
||||
digital::*
|
||||
};
|
||||
use core::marker::Sized;
|
||||
|
||||
|
||||
use drawing::color::Color;
|
||||
|
||||
/// Interface for the physical connection between display and the controlling device
|
||||
pub mod connection_interface;
|
||||
|
||||
//TODO: test spi mode
|
||||
/// SPI mode -
|
||||
/// For more infos see [Requirements: SPI](index.html#spi)
|
||||
pub const SPI_MODE: Mode = Mode {
|
||||
phase: Phase::CaptureOnFirstTransition,
|
||||
polarity: Polarity::IdleLow,
|
||||
};
|
||||
|
||||
use core::marker::Sized;
|
||||
|
||||
/// 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)
|
||||
pub(crate) trait Command {
|
||||
fn address(self) -> u8;
|
||||
}
|
||||
|
||||
|
||||
//TODO add LUT trait with set_fast_lut
|
||||
// and set_manual_lut and set_normal_lut or sth like that
|
||||
//TODO: add LUT trait with set_fast_lut and set_manual_lut and set_normal_lut or sth like that?
|
||||
// for partial updates
|
||||
|
||||
pub trait LUTSupport<Error> {
|
||||
trait LUTSupport<Error> {
|
||||
fn set_lut(&mut self) -> Result<(), Error>;
|
||||
fn set_lut_quick(&mut self) -> Result<(), Error>;
|
||||
fn set_lut_manual(&mut self, data: &[u8]) -> Result<(), Error>;
|
||||
|
|
@ -122,37 +115,4 @@ pub trait WaveshareInterface<SPI, CS, BUSY, DC, RST, D, E>
|
|||
///
|
||||
/// maximum delay ~65 seconds (u16:max in ms)
|
||||
fn delay_ms(&mut self, delay: u16);
|
||||
|
||||
/*
|
||||
|
||||
|
||||
//
|
||||
-set_quick_lut?
|
||||
-set_normal_mode
|
||||
|
||||
|
||||
fn clear_frame(&mut self, reset_color: Option<Color>) -> Result<(), E>
|
||||
|
||||
fn display_frame_quick(&mut self) -> Result<(), E>
|
||||
|
||||
fn display_frame(&mut self) -> Result<(), E>
|
||||
|
||||
pub fn display_and_transfer_frame(
|
||||
&mut self,
|
||||
buffer: &[u8],
|
||||
color: Option<u8>
|
||||
) -> Result<(), E>
|
||||
|
||||
pub fn set_partial_window(
|
||||
&mut self,
|
||||
buffer: &[u8],
|
||||
x: u16,
|
||||
y: u16,
|
||||
w: u16,
|
||||
l: u16,
|
||||
is_dtm1: bool
|
||||
) -> Result<(), E>
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
12
src/lib.rs
12
src/lib.rs
|
|
@ -1,11 +1,5 @@
|
|||
//! A simple Driver for the Waveshare E-Ink Displays via SPI
|
||||
//!
|
||||
//! The other Waveshare E-Ink Displays should be added later on, atm it's only the 4.2"-Display
|
||||
//!
|
||||
//! Build with the help of documentation/code from [Waveshare](https://www.waveshare.com/wiki/4.2inch_e-Paper_Module),
|
||||
//! [Ben Krasnows partial Refresh tips](https://benkrasnow.blogspot.de/2017/10/fast-partial-refresh-on-42-e-paper.html) and
|
||||
//! the driver documents in the `pdfs`-folder as orientation.
|
||||
//!
|
||||
//! This driver was built using [`embedded-hal`] traits.
|
||||
//!
|
||||
//! [`embedded-hal`]: https://docs.rs/embedded-hal/~0.1
|
||||
|
|
@ -45,12 +39,10 @@
|
|||
//! ```
|
||||
//!
|
||||
//!
|
||||
//! BE CAREFUL! The Partial Drawing can "destroy" your display.
|
||||
//! It needs more testing first.
|
||||
//!
|
||||
//! TODO: Make more assertions about buffersizes?
|
||||
#![no_std]
|
||||
|
||||
//TODO: Make more assertions about buffersizes?
|
||||
|
||||
|
||||
extern crate embedded_hal as hal;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue