From 89489da657951e10bfd9dfa93660606961067a68 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 10 Oct 2018 17:01:03 +0200 Subject: [PATCH] Renaming of WaveshareInterface and Connectioninterface WaveshareInterface -> WaveshareDisplay traits::interface::ConnectionInterface -> interface::DisplayInterface --- src/epd1in54/mod.rs | 10 +++++----- src/epd2in9/mod.rs | 8 ++++---- src/epd4in2/mod.rs | 9 +++++---- src/{traits/connection_interface.rs => interface.rs} | 11 +++++------ src/lib.rs | 5 ++++- src/{traits/mod.rs => traits.rs} | 0 6 files changed, 23 insertions(+), 20 deletions(-) rename src/{traits/connection_interface.rs => interface.rs} (93%) rename src/{traits/mod.rs => traits.rs} (100%) diff --git a/src/epd1in54/mod.rs b/src/epd1in54/mod.rs index d220532..35e47d0 100644 --- a/src/epd1in54/mod.rs +++ b/src/epd1in54/mod.rs @@ -33,15 +33,15 @@ use type_a::{command::Command, LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE}; use color::Color; -use traits::{WaveshareInterface}; +use traits::{WaveshareDisplay}; -use traits::connection_interface::ConnectionInterface; +use interface::DisplayInterface; /// EPD1in54 driver /// pub struct EPD1in54 { /// SPI - interface: ConnectionInterface, + interface: DisplayInterface, /// EPD (width, height) //epd: EPD, /// Color @@ -95,7 +95,7 @@ where } -impl WaveshareInterface +impl WaveshareDisplay for EPD1in54 where SPI: Write, @@ -115,7 +115,7 @@ where fn new>( spi: &mut SPI, cs: CS, busy: BUSY, dc: DC, rst: RST, delay: &mut DELAY, ) -> Result { - let interface = ConnectionInterface::new(cs, busy, dc, rst); + let interface = DisplayInterface::new(cs, busy, dc, rst); let mut epd = EPD1in54 { interface, diff --git a/src/epd2in9/mod.rs b/src/epd2in9/mod.rs index c154d19..1110d11 100644 --- a/src/epd2in9/mod.rs +++ b/src/epd2in9/mod.rs @@ -34,13 +34,13 @@ use color::Color; use traits::*; -use traits::connection_interface::ConnectionInterface; +use interface::DisplayInterface; /// EPD2in9 driver /// pub struct EPD2in9 { /// SPI - interface: ConnectionInterface, + interface: DisplayInterface, /// EPD (width, height) //epd: EPD, /// Color @@ -90,7 +90,7 @@ where } impl - WaveshareInterface + WaveshareDisplay for EPD2in9 where SPI: Write, @@ -110,7 +110,7 @@ where fn new>( spi: &mut SPI, cs: CS, busy: BUSY, dc: DC, rst: RST, delay: &mut DELAY, ) -> Result { - let interface = ConnectionInterface::new(cs, busy, dc, rst); + let interface = DisplayInterface::new(cs, busy, dc, rst); let mut epd = EPD2in9 { interface, diff --git a/src/epd4in2/mod.rs b/src/epd4in2/mod.rs index a51371d..87fa40f 100644 --- a/src/epd4in2/mod.rs +++ b/src/epd4in2/mod.rs @@ -51,7 +51,8 @@ use hal::{ digital::*, }; -use traits::{connection_interface::ConnectionInterface, WaveshareInterface, InternalWiAdditions}; +use traits::{WaveshareDisplay, InternalWiAdditions}; +use interface::DisplayInterface; //The Lookup Tables for the Display mod constants; @@ -66,7 +67,7 @@ use self::command::Command; /// pub struct EPD4in2 { /// Connection Interface - interface: ConnectionInterface, + interface: DisplayInterface, /// Background Color color: Color, } @@ -114,7 +115,7 @@ where } impl - WaveshareInterface + WaveshareDisplay for EPD4in2 where SPI: Write, @@ -139,7 +140,7 @@ where /// epd4in2.sleep(); /// ``` fn new>(spi: &mut SPI, cs: CS, busy: BUSY, dc: DC, rst: RST, delay: &mut DELAY) -> Result { - let interface = ConnectionInterface::new(cs, busy, dc, rst); + let interface = DisplayInterface::new(cs, busy, dc, rst); let color = DEFAULT_BACKGROUND_COLOR; let mut epd = EPD4in2 { diff --git a/src/traits/connection_interface.rs b/src/interface.rs similarity index 93% rename from src/traits/connection_interface.rs rename to src/interface.rs index 0a18c86..623a2fc 100644 --- a/src/traits/connection_interface.rs +++ b/src/interface.rs @@ -2,14 +2,12 @@ use hal::{ blocking::{delay::*, spi::Write}, digital::*, }; - use core::marker::PhantomData; - use traits::Command; /// The Connection Interface of all (?) Waveshare EPD-Devices /// -pub(crate) struct ConnectionInterface { +pub(crate) struct DisplayInterface { /// SPI _spi: PhantomData, /// CS for SPI @@ -23,7 +21,7 @@ pub(crate) struct ConnectionInterface { } impl - ConnectionInterface + DisplayInterface where SPI: Write, CS: OutputPin, @@ -32,7 +30,7 @@ where RST: OutputPin, { pub fn new(cs: CS, busy: BUSY, dc: DC, rst: RST) -> Self { - ConnectionInterface { + DisplayInterface { _spi: PhantomData::default(), cs, busy, @@ -43,7 +41,7 @@ where /// Basic function for sending [Commands](Command). /// - /// Enables direct interaction with the device with the help of [data()](ConnectionInterface::data()) + /// Enables direct interaction with the device with the help of [data()](DisplayInterface::data()) /// /// //TODO: make public? pub(crate) fn cmd(&mut self, spi: &mut SPI, command: T) -> Result<(), SPI::Error> { @@ -70,6 +68,7 @@ where /// Basic function for sending [Commands](Command) and the data belonging to it. /// /// //TODO: make public? + /// TODO: directly use ::write? cs wouldn't needed to be changed twice than pub(crate) fn cmd_with_data(&mut self, spi: &mut SPI, command: T, data: &[u8]) -> Result<(), SPI::Error> { self.cmd(spi, command)?; self.data(spi, data) diff --git a/src/lib.rs b/src/lib.rs index 5e34505..6492411 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,10 +51,13 @@ use hal::spi::{Mode, Phase, Polarity}; pub mod drawing; mod traits; -pub use traits::{WaveshareInterface}; +pub use traits::{WaveshareDisplay}; pub mod color; +/// Interface for the physical connection between display and the controlling device +mod interface; + #[cfg(feature = "epd4in2")] mod epd4in2; #[cfg(feature = "epd4in2")] diff --git a/src/traits/mod.rs b/src/traits.rs similarity index 100% rename from src/traits/mod.rs rename to src/traits.rs