improved traits, now it should be ready to convert 4.2"

This commit is contained in:
Christoph Groß
2018-07-19 11:08:26 +02:00
parent ceee294cda
commit 80e5c0ffb1
4 changed files with 120 additions and 57 deletions
+9 -5
View File
@@ -1,5 +1,8 @@
//! SPI Commands for the Waveshare 2.9" E-Ink Display
use interface;
/// EPD2IN9 commands
///
/// Should rarely (never?) be needed directly.
@@ -10,7 +13,7 @@
#[allow(dead_code)]
#[allow(non_camel_case_types)]
#[derive(Copy, Clone)]
pub(crate) enum Command {
pub enum Command {
/// Driver Output control
/// 3 Databytes:
/// A[7:0]
@@ -39,9 +42,9 @@ pub(crate) enum Command {
impl Command {
impl interface::Command for Command {
/// Returns the address of the command
pub fn addr(self) -> u8 {
fn address(self) -> u8 {
self as u8
}
}
@@ -49,11 +52,12 @@ impl Command {
#[cfg(test)]
mod tests {
use super::*;
use super::Command;
use interface::Command as CommandTrait;
#[test]
fn command_addr() {
//assert_eq!(Command::POWER_SAVING.addr(), 0xE3);
assert_eq!(Command::DRIVER_OUTPUT_CONTROL.address(), 0x01);
//assert_eq!(Command::PANEL_SETTING.addr(), 0x00);
+33 -9
View File
@@ -53,7 +53,6 @@ use hal::{
spi::Write,
delay::*
},
spi::{Mode, Phase, Polarity},
digital::*
};
@@ -69,7 +68,7 @@ use interface::*;
use interface::data_interface::DataInterface;
/// EPD4in2 driver
/// EPD2in9 driver
///
pub struct EPD2in9<SPI, CS, BUSY, DC, RST, D> {
/// SPI
@@ -80,7 +79,6 @@ pub struct EPD2in9<SPI, CS, BUSY, DC, RST, D> {
height: u32,
}
impl<SPI, CS, BUSY, DC, RST, D, E> EPD2in9<SPI, CS, BUSY, DC, RST, D>
where
SPI: Write<u8, Error = E>,
@@ -103,6 +101,7 @@ where
RST: OutputPin,
D: DelayUs<u16> + DelayMs<u16>,
{
fn get_width(&self) -> u32 {
self.width
}
@@ -136,20 +135,45 @@ where
fn init(&mut self) -> Result<(), E> {
//TODO:
Ok(())
unimplemented!()
}
fn sleep(&mut self) -> Result<(), E> {
Ok(())
unimplemented!()
}
fn reset(&mut self) {
//TODO:
self.interface.reset()
}
fn wait_until_idle(&mut self) {
fn delay_ms(&mut self, delay: u16) {
self.interface.delay_ms(delay)
}
fn delay_ms(&mut self, delay: u32) {
fn update_frame(&mut self, buffer: &[u8]) -> Result<(), E>{
unimplemented!()
}
fn update_partial_frame(&mut self, buffer: &[u8], x: u16, y: u16, width: u16, height: u16) -> Result<(), E>{
unimplemented!()
}
fn display_frame(&mut self) -> Result<(), E>{
unimplemented!()
}
// TODO: add this abstraction function
// fn update_and_display_frame(&mut self, buffer: &[u8]) -> Result<(), E>;
fn clear_frame(&mut self) -> Result<(), E>{
unimplemented!()
}
/// Sets the backgroundcolor for various commands like [WaveshareInterface::clear_frame()](clear_frame())
fn set_background_color(&mut self, color: Color){
unimplemented!()
}
}