mirror of
https://github.com/Anshorei/epd-waveshare.git
synced 2026-10-03 22:06:43 +00:00
Stablised traits and interfaces, converted epd4in2 to it, and started real work on epd2in9
This commit is contained in:
+34
-1
@@ -10,7 +10,7 @@ use interface;
|
||||
/// For more infos about the addresses and what they are doing look into the pdfs
|
||||
///
|
||||
/// The description of the single commands is mostly taken from IL0398.pdf
|
||||
#[allow(dead_code)]
|
||||
//#[allow(dead_code)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum Command {
|
||||
@@ -38,6 +38,39 @@ pub enum Command {
|
||||
/// A[0] = 1: Enter Deep Sleep Mode
|
||||
DEEP_SLEEP_MODE = 0x10,
|
||||
// /// Data Entry mode setting
|
||||
DATA_ENTRY_MODE_SETTING = 0x11,
|
||||
|
||||
SW_RESET = 0x12,
|
||||
|
||||
TEMPERATURE_SENSOR_CONTROL = 0x1A,
|
||||
|
||||
MASTER_ACTIVATION = 0x20,
|
||||
|
||||
DISPLAY_UPDATE_CONTROL_1 = 0x21,
|
||||
|
||||
DISPLAY_UPDATE_CONTROL_2 = 0x22,
|
||||
|
||||
WRITE_RAM = 0x24,
|
||||
|
||||
WRITE_VCOM_REGISTER = 0x2C,
|
||||
|
||||
WRITE_LUT_REGISTER = 0x32,
|
||||
|
||||
SET_DUMMY_LINE_PERIOD = 0x3A,
|
||||
|
||||
SET_GATE_TIME = 0x3B,
|
||||
|
||||
BORDER_WAVEFORM_CONTROL = 0x3C,
|
||||
|
||||
SET_RAM_X_ADDRESS_START_END_POSITION = 0x44,
|
||||
|
||||
SET_RAM_Y_ADDRESS_START_END_POSITION = 0x45,
|
||||
|
||||
SET_RAM_X_ADDRESS_COUNTER = 0x4E,
|
||||
|
||||
SET_RAM_Y_ADDRESS_COUNTER = 0x4F,
|
||||
|
||||
TERMINATE_COMMANDS_AND_FRAME_WRITE = 0xFF
|
||||
}
|
||||
|
||||
|
||||
|
||||
+30
-8
@@ -62,21 +62,23 @@ use self::constants::*;
|
||||
use drawing::color::Color;
|
||||
|
||||
pub mod command;
|
||||
pub use command::Command as Command;
|
||||
pub use self::command::Command;
|
||||
|
||||
use interface::*;
|
||||
|
||||
use interface::data_interface::DataInterface;
|
||||
use interface::connection_interface::ConnectionInterface;
|
||||
|
||||
/// EPD2in9 driver
|
||||
///
|
||||
pub struct EPD2in9<SPI, CS, BUSY, DC, RST, D> {
|
||||
/// SPI
|
||||
interface: DataInterface<SPI, CS, BUSY, DC, RST, D>,
|
||||
interface: ConnectionInterface<SPI, CS, BUSY, DC, RST, D>,
|
||||
/// Width
|
||||
width: u32,
|
||||
/// Height
|
||||
height: u32,
|
||||
height: u32,
|
||||
/// Color
|
||||
color: Color,
|
||||
}
|
||||
|
||||
impl<SPI, CS, BUSY, DC, RST, D, E> EPD2in9<SPI, CS, BUSY, DC, RST, D>
|
||||
@@ -122,9 +124,11 @@ where
|
||||
let width = WIDTH as u32;
|
||||
let height = HEIGHT as u32;
|
||||
|
||||
let mut interface = DataInterface::new(spi, cs, busy, dc, rst, delay);
|
||||
let interface = ConnectionInterface::new(spi, cs, busy, dc, rst, delay);
|
||||
|
||||
let mut epd = EPD2in9 {interface, width, height};
|
||||
let color = Color::White;
|
||||
|
||||
let mut epd = EPD2in9 {interface, width, height, color};
|
||||
|
||||
|
||||
epd.init()?;
|
||||
@@ -135,11 +139,26 @@ where
|
||||
|
||||
|
||||
fn init(&mut self) -> Result<(), E> {
|
||||
self.reset();
|
||||
|
||||
|
||||
|
||||
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn sleep(&mut self) -> Result<(), E> {
|
||||
unimplemented!()
|
||||
|
||||
self.interface.send_command(Command::DEEP_SLEEP_MODE)?;
|
||||
// 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode
|
||||
//TODO: is 0x00 needed here?
|
||||
self.interface.send_data(0x00)?;
|
||||
|
||||
self.interface.wait_until_idle(false);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
fn reset(&mut self) {
|
||||
self.interface.reset()
|
||||
}
|
||||
@@ -165,6 +184,9 @@ where
|
||||
|
||||
// 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<(), E>{
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
||||
fn clear_frame(&mut self) -> Result<(), E>{
|
||||
@@ -173,7 +195,7 @@ where
|
||||
|
||||
/// Sets the backgroundcolor for various commands like [WaveshareInterface::clear_frame()](clear_frame())
|
||||
fn set_background_color(&mut self, color: Color){
|
||||
unimplemented!()
|
||||
self.color = color;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user