diff --git a/Cargo.toml b/Cargo.toml index 132293a..009f893 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ name = "epd-waveshare" readme = "README.md" repository = "https://github.com/Caemor/epd-waveshare.git" version = "0.2.0" +edition = "2018" [badges] # Travis CI: `repository` in format "/" is required. diff --git a/README.md b/README.md index 92663e9..8902dc7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ [![Build Status](https://travis-ci.com/caemor/epd-waveshare.svg?branch=master)](https://travis-ci.com/caemor/epd-waveshare) -This library contains a driver for E-Paper Modules from Waveshare. +This library contains a driver for E-Paper Modules from Waveshare. It uses the [embedded graphics](https://crates.io/crates/embedded-graphics) library for the optional graphics support. +A 2018-edition compatible version (Rust 1.31+) is needed. + ## Examples There are multiple examples in the examples folder. For more infos about the examples see the seperate Readme [there](/examples/Readme.md). diff --git a/src/epd1in54/graphics.rs b/src/epd1in54/graphics.rs index b787574..5fe2417 100644 --- a/src/epd1in54/graphics.rs +++ b/src/epd1in54/graphics.rs @@ -1,4 +1,4 @@ -use epd1in54::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH}; +use crate::epd1in54::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH}; /// Full size buffer for use with the 1in54 EPD /// @@ -20,11 +20,11 @@ impl Default for Buffer1in54BlackWhite { #[cfg(test)] mod tests { use super::*; - use color::Color; + use crate::color::Color; + use crate::graphics::{Display, DisplayRotation}; use embedded_graphics::coord::Coord; use embedded_graphics::prelude::*; use embedded_graphics::primitives::Line; - use graphics::{Display, DisplayRotation}; // test buffer length #[test] diff --git a/src/epd1in54/mod.rs b/src/epd1in54/mod.rs index a7c00ff..20c6f7d 100644 --- a/src/epd1in54/mod.rs +++ b/src/epd1in54/mod.rs @@ -38,24 +38,24 @@ pub const HEIGHT: u32 = 200; //const DPI: u16 = 184; pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; -use hal::{ +use embedded_hal::{ blocking::{delay::*, spi::Write}, digital::*, }; -use type_a::{ +use crate::type_a::{ command::Command, constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE}, }; -use color::Color; +use crate::color::Color; -use traits::{RefreshLUT, WaveshareDisplay}; +use crate::traits::{RefreshLUT, WaveshareDisplay}; -use interface::DisplayInterface; +use crate::interface::DisplayInterface; mod graphics; -pub use epd1in54::graphics::Buffer1in54BlackWhite as Buffer1in54; +pub use crate::epd1in54::graphics::Buffer1in54BlackWhite as Buffer1in54; /// EPD1in54 driver /// diff --git a/src/epd2in9/graphics.rs b/src/epd2in9/graphics.rs index 044338a..a2ba8cb 100644 --- a/src/epd2in9/graphics.rs +++ b/src/epd2in9/graphics.rs @@ -1,4 +1,4 @@ -use epd2in9::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH}; +use crate::epd2in9::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH}; /// Full size buffer for use with the 2in9 EPD /// @@ -20,7 +20,7 @@ impl Default for Buffer2in9 { #[cfg(test)] mod tests { use super::*; - use graphics::Display; + use crate::graphics::Display; // test buffer length #[test] diff --git a/src/epd2in9/mod.rs b/src/epd2in9/mod.rs index d28114a..e7de76f 100644 --- a/src/epd2in9/mod.rs +++ b/src/epd2in9/mod.rs @@ -39,24 +39,24 @@ pub const WIDTH: u32 = 128; pub const HEIGHT: u32 = 296; pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; -use hal::{ +use embedded_hal::{ blocking::{delay::*, spi::Write}, digital::*, }; -use type_a::{ +use crate::type_a::{ command::Command, constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE}, }; -use color::Color; +use crate::color::Color; -use traits::*; +use crate::traits::*; -use interface::DisplayInterface; +use crate::interface::DisplayInterface; mod graphics; -pub use epd2in9::graphics::Buffer2in9; +pub use crate::epd2in9::graphics::Buffer2in9; /// EPD2in9 driver /// diff --git a/src/epd4in2/command.rs b/src/epd4in2/command.rs index 60173e8..0d220b1 100644 --- a/src/epd4in2/command.rs +++ b/src/epd4in2/command.rs @@ -1,5 +1,5 @@ //! SPI Commands for the Waveshare 4.2" E-Ink Display -use traits; +use crate::traits; /// EPD4IN2 commands /// /// Should rarely (never?) be needed directly. @@ -165,7 +165,7 @@ impl traits::Command for Command { #[cfg(test)] mod tests { use super::*; - use traits::Command as CommandTrait; + use crate::traits::Command as CommandTrait; #[test] fn command_addr() { diff --git a/src/epd4in2/constants.rs b/src/epd4in2/constants.rs index 0821cb2..0578335 100644 --- a/src/epd4in2/constants.rs +++ b/src/epd4in2/constants.rs @@ -1,4 +1,4 @@ -use color::Color; +use crate::color::Color; pub const WIDTH: u32 = 400; pub const HEIGHT: u32 = 300; diff --git a/src/epd4in2/graphics.rs b/src/epd4in2/graphics.rs index da22261..5e656e8 100644 --- a/src/epd4in2/graphics.rs +++ b/src/epd4in2/graphics.rs @@ -1,4 +1,4 @@ -use epd4in2::constants::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH}; +use crate::epd4in2::constants::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH}; /// Full size buffer for use with the 4in2 EPD /// @@ -20,12 +20,12 @@ impl Default for Buffer4in2 { #[cfg(test)] mod tests { use super::*; - use color::Color; + use crate::color::Color; + use crate::epd4in2; + use crate::graphics::{Display, DisplayRotation}; use embedded_graphics::coord::Coord; use embedded_graphics::prelude::*; use embedded_graphics::primitives::Line; - use epd4in2; - use graphics::{Display, DisplayRotation}; // test buffer length #[test] @@ -40,7 +40,7 @@ mod tests { fn graphics_default() { let mut display4in2 = Buffer4in2::default(); let display = Display::new(WIDTH, HEIGHT, &mut display4in2.buffer); - use epd4in2; + use crate::epd4in2; for &byte in display.buffer() { assert_eq!( byte, diff --git a/src/epd4in2/mod.rs b/src/epd4in2/mod.rs index 7775690..234ff2c 100644 --- a/src/epd4in2/mod.rs +++ b/src/epd4in2/mod.rs @@ -46,19 +46,19 @@ //! //! BE CAREFUL! The screen can get ghosting/burn-ins through the Partial Fast Update Drawing. -use hal::{ +use embedded_hal::{ blocking::{delay::*, spi::Write}, digital::*, }; -use interface::DisplayInterface; -use traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay}; +use crate::interface::DisplayInterface; +use crate::traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay}; //The Lookup Tables for the Display mod constants; pub use self::constants::*; -use color::Color; +use crate::color::Color; pub(crate) mod command; use self::command::Command; diff --git a/src/graphics.rs b/src/graphics.rs index df28f0f..52cef7e 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -1,6 +1,6 @@ //! Graphics Support for EPDs -use color::Color; +use crate::color::Color; use embedded_graphics::prelude::*; /// Displayrotation @@ -129,14 +129,14 @@ fn rotation(x: u32, y: u32, width: u32, height: u32, rotation: DisplayRotation) #[cfg(test)] mod tests { use super::{outside_display, rotation, Display, DisplayRotation}; - use color::Color; + use crate::color::Color; use embedded_graphics::coord::Coord; use embedded_graphics::prelude::*; use embedded_graphics::primitives::Line; #[test] fn buffer_clear() { - use epd4in2::{HEIGHT, WIDTH}; + use crate::epd4in2::{HEIGHT, WIDTH}; let mut buffer = [Color::Black.get_byte_value(); WIDTH as usize / 8 * HEIGHT as usize]; let mut display = Display::new(WIDTH, HEIGHT, &mut buffer); @@ -154,7 +154,7 @@ mod tests { #[test] fn rotation_overflow() { - use epd4in2::{HEIGHT, WIDTH}; + use crate::epd4in2::{HEIGHT, WIDTH}; let width = WIDTH as u32; let height = HEIGHT as u32; test_rotation_overflow(width, height, DisplayRotation::Rotate0); @@ -180,7 +180,7 @@ mod tests { #[test] fn graphics_rotation_0() { - use epd2in9::DEFAULT_BACKGROUND_COLOR; + use crate::epd2in9::DEFAULT_BACKGROUND_COLOR; let width = 128; let height = 296; @@ -204,7 +204,7 @@ mod tests { #[test] fn graphics_rotation_90() { - use epd2in9::DEFAULT_BACKGROUND_COLOR; + use crate::epd2in9::DEFAULT_BACKGROUND_COLOR; let width = 128; let height = 296; diff --git a/src/interface.rs b/src/interface.rs index 179dd77..c046a47 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -1,9 +1,9 @@ +use crate::traits::Command; use core::marker::PhantomData; -use hal::{ +use embedded_hal::{ blocking::{delay::*, spi::Write}, digital::*, }; -use traits::Command; /// The Connection Interface of all (?) Waveshare EPD-Devices /// diff --git a/src/lib.rs b/src/lib.rs index 0a120af..d210ed9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,9 +41,6 @@ //! #![no_std] -#[cfg(feature = "graphics")] -extern crate embedded_graphics; - #[cfg(feature = "graphics")] pub mod graphics; @@ -67,13 +64,12 @@ pub mod epd2in9; pub(crate) mod type_a; pub mod prelude { - pub use color::Color; - pub use traits::{RefreshLUT, WaveshareDisplay}; - pub use SPI_MODE; + pub use crate::color::Color; + pub use crate::traits::{RefreshLUT, WaveshareDisplay}; + pub use crate::SPI_MODE; } -extern crate embedded_hal as hal; -use hal::spi::{Mode, Phase, Polarity}; +use embedded_hal::spi::{Mode, Phase, Polarity}; /// SPI mode - /// For more infos see [Requirements: SPI](index.html#spi) diff --git a/src/traits.rs b/src/traits.rs index 7ea2857..2b5dc33 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -1,6 +1,6 @@ -use color::Color; +use crate::color::Color; use core::marker::Sized; -use hal::{ +use embedded_hal::{ blocking::{delay::*, spi::Write}, digital::*, }; diff --git a/src/type_a/command.rs b/src/type_a/command.rs index 36d6027..30a2df6 100644 --- a/src/type_a/command.rs +++ b/src/type_a/command.rs @@ -1,6 +1,6 @@ //! SPI Commands for the Waveshare 2.9" and 1.54" E-Ink Display -use traits; +use crate::traits; /// EPD1in54 and EPD2IN9 commands /// @@ -81,7 +81,7 @@ impl traits::Command for Command { #[cfg(test)] mod tests { use super::Command; - use traits::Command as CommandTrait; + use crate::traits::Command as CommandTrait; #[test] fn command_addr() {