Edition 2018 (#24)

* "cargo fix --edition" for the library

* Switch to 2018 edition

* Use cargo fix edition-idioms and remove the internal renaming from embedded_hal to hal

* Updated Readme

* run cargo fmt
This commit is contained in:
Chris 2019-02-22 11:23:28 +01:00 committed by GitHub
parent 91b723d30e
commit d7f3cdca97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 49 additions and 50 deletions

View File

@ -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 "<user>/<project>" is required.

View File

@ -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).

View File

@ -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]

View File

@ -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
///

View File

@ -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]

View File

@ -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
///

View File

@ -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() {

View File

@ -1,4 +1,4 @@
use color::Color;
use crate::color::Color;
pub const WIDTH: u32 = 400;
pub const HEIGHT: u32 = 300;

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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
///

View File

@ -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)

View File

@ -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::*,
};

View File

@ -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() {