Updated to eh a6, delay not yet catched
parent
0c5a40579f
commit
9d0e78bc15
|
|
@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- Updated to embedded hal 1.0 a6
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
## [v0.5.0] - 2021-11-28
|
## [v0.5.0] - 2021-11-28
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ edition = "2018"
|
||||||
# travis-ci = { repository = "caemor/epd-waveshare" }
|
# travis-ci = { repository = "caemor/epd-waveshare" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embedded-hal = "1.0.0-alpha.2"
|
embedded-hal = "1.0.0-alpha.6"
|
||||||
embedded-graphics-core = { version = "0.3.2", optional = true}
|
embedded-graphics-core = { version = "0.3.2", optional = true}
|
||||||
bit_field = "0.10.1"
|
bit_field = "0.10.1"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
use embedded_hal::prelude::*;
|
|
||||||
use epd_waveshare::{epd1in54::Epd1in54, prelude::*};
|
use epd_waveshare::{epd1in54::Epd1in54, prelude::*};
|
||||||
use linux_embedded_hal::{
|
use linux_embedded_hal::{
|
||||||
spidev::{self, SpidevOptions},
|
spidev::{self, SpidevOptions},
|
||||||
|
|
|
||||||
|
|
@ -53,14 +53,10 @@ pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
|
||||||
//const DPI: u16 = 184;
|
//const DPI: u16 = 184;
|
||||||
const IS_BUSY_LOW: bool = false;
|
const IS_BUSY_LOW: bool = false;
|
||||||
|
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::type_a::{
|
use crate::type_a::{
|
||||||
command::Command,
|
command::Command,
|
||||||
constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE},
|
constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE}
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
|
|
@ -91,7 +87,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10);
|
||||||
|
|
@ -147,7 +143,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn width(&self) -> u32 {
|
fn width(&self) -> u32 {
|
||||||
|
|
@ -296,7 +292,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
let _ = self.interface.wait_until_idle(IS_BUSY_LOW);
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
//! A simple Driver for the Waveshare 1.54" (B) E-Ink Display via SPI
|
//! A simple Driver for the Waveshare 1.54" (B) E-Ink Display via SPI
|
||||||
|
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
||||||
|
|
@ -46,7 +42,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10);
|
||||||
|
|
@ -61,7 +57,7 @@ where
|
||||||
|
|
||||||
// power on
|
// power on
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
delay.try_delay_ms(5);
|
delay.delay_ms(5);
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// set the panel settings
|
// set the panel settings
|
||||||
|
|
@ -93,7 +89,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn update_color_frame(
|
fn update_color_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -137,7 +133,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new(
|
fn new(
|
||||||
|
|
@ -313,7 +309,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
//! A simple Driver for the Waveshare 1.54" (C) E-Ink Display via SPI
|
//! A simple Driver for the Waveshare 1.54" (C) E-Ink Display via SPI
|
||||||
|
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::v2::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
||||||
|
|
@ -44,7 +40,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
// Based on Reference Program Code from:
|
// Based on Reference Program Code from:
|
||||||
|
|
@ -81,7 +77,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn update_color_frame(
|
fn update_color_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -120,7 +116,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new(
|
fn new(
|
||||||
|
|
@ -255,7 +251,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,7 @@
|
||||||
//! - [Controller Datasheet SS1780](http://www.e-paper-display.com/download_detail/downloadsId=682.html)
|
//! - [Controller Datasheet SS1780](http://www.e-paper-display.com/download_detail/downloadsId=682.html)
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::{InputPin, OutputPin},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::buffer_len;
|
use crate::buffer_len;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
|
|
@ -64,7 +60,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
// HW reset
|
// HW reset
|
||||||
|
|
@ -158,7 +154,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new(
|
fn new(
|
||||||
|
|
@ -368,7 +364,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
/// When using partial refresh, the controller uses the provided buffer for
|
/// When using partial refresh, the controller uses the provided buffer for
|
||||||
/// comparison with new buffer.
|
/// comparison with new buffer.
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,8 @@
|
||||||
//!# Ok(())
|
//!# Ok(())
|
||||||
//!# }
|
//!# }
|
||||||
//!```
|
//!```
|
||||||
use embedded_hal::{
|
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::v2::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
use crate::eh_prelude::*;
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
||||||
|
|
@ -100,7 +97,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
// Values taken from datasheet and sample code
|
// Values taken from datasheet and sample code
|
||||||
|
|
@ -144,7 +141,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn update_color_frame(
|
fn update_color_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -189,7 +186,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = TriColor;
|
type DisplayColor = TriColor;
|
||||||
fn new(
|
fn new(
|
||||||
|
|
@ -336,7 +333,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! [Documentation](https://www.waveshare.com/wiki/2.7inch_e-Paper_HAT_(B))
|
//! [Documentation](https://www.waveshare.com/wiki/2.7inch_e-Paper_HAT_(B))
|
||||||
|
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::v2::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
||||||
|
|
@ -50,7 +46,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
// reset the device
|
// reset the device
|
||||||
|
|
@ -116,7 +112,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new(
|
fn new(
|
||||||
|
|
@ -275,7 +271,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn update_color_frame(
|
fn update_color_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -328,7 +324,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,7 @@ pub const HEIGHT: u32 = 296;
|
||||||
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
|
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
|
||||||
const IS_BUSY_LOW: bool = false;
|
const IS_BUSY_LOW: bool = false;
|
||||||
|
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::type_a::{
|
use crate::type_a::{
|
||||||
command::Command,
|
command::Command,
|
||||||
constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE},
|
constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE},
|
||||||
|
|
@ -88,7 +84,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10);
|
||||||
|
|
@ -140,7 +136,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn width(&self) -> u32 {
|
fn width(&self) -> u32 {
|
||||||
|
|
@ -292,7 +288,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
let _ = self.interface.wait_until_idle(IS_BUSY_LOW);
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW);
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,7 @@ const LUT_PARTIAL_2IN9: [u8; 153] = [
|
||||||
0x22, 0x0, 0x0, 0x0,
|
0x22, 0x0, 0x0, 0x0,
|
||||||
];
|
];
|
||||||
|
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::v2::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::type_a::command::Command;
|
use crate::type_a::command::Command;
|
||||||
|
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
|
|
@ -111,7 +107,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2);
|
||||||
|
|
@ -153,7 +149,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn width(&self) -> u32 {
|
fn width(&self) -> u32 {
|
||||||
|
|
@ -289,7 +285,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW);
|
self.interface.wait_until_idle(IS_BUSY_LOW);
|
||||||
|
|
@ -369,7 +365,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
/// To be followed immediately by `update_new_frame`.
|
/// To be followed immediately by `update_new_frame`.
|
||||||
fn update_old_frame(
|
fn update_old_frame(
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,8 @@
|
||||||
//!# Ok(())
|
//!# Ok(())
|
||||||
//!# }
|
//!# }
|
||||||
//!```
|
//!```
|
||||||
use embedded_hal::{
|
//!
|
||||||
blocking::{delay::*, spi::Write},
|
use crate::eh_prelude::*;
|
||||||
digital::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
||||||
|
|
@ -103,7 +100,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
// Values taken from datasheet and sample code
|
// Values taken from datasheet and sample code
|
||||||
|
|
@ -116,7 +113,7 @@ where
|
||||||
|
|
||||||
// power on
|
// power on
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
delay.try_delay_ms(5);
|
delay.delay_ms(5);
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// set the panel settings
|
// set the panel settings
|
||||||
|
|
@ -147,7 +144,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn update_color_frame(
|
fn update_color_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -192,7 +189,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new(
|
fn new(
|
||||||
|
|
@ -339,7 +336,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,7 @@
|
||||||
//!
|
//!
|
||||||
//! BE CAREFUL! The screen can get ghosting/burn-ins through the Partial Fast Update Drawing.
|
//! BE CAREFUL! The screen can get ghosting/burn-ins through the Partial Fast Update Drawing.
|
||||||
|
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{InternalWiAdditions, QuickRefresh, RefreshLut, WaveshareDisplay};
|
use crate::traits::{InternalWiAdditions, QuickRefresh, RefreshLut, WaveshareDisplay};
|
||||||
|
|
||||||
|
|
@ -98,7 +94,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
// reset the device
|
// reset the device
|
||||||
|
|
@ -117,7 +113,7 @@ where
|
||||||
|
|
||||||
// power on
|
// power on
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
delay.try_delay_ms(5);
|
delay.delay_ms(5);
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// set the panel settings
|
// set the panel settings
|
||||||
|
|
@ -153,7 +149,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new(
|
fn new(
|
||||||
|
|
@ -349,7 +345,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
@ -447,7 +443,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
/// To be followed immediately after by `update_old_frame`.
|
/// To be followed immediately after by `update_old_frame`.
|
||||||
fn update_old_frame(
|
fn update_old_frame(
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,7 @@
|
||||||
//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_5in65f.c)
|
//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_5in65f.c)
|
||||||
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd5in65f.py)
|
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd5in65f.py)
|
||||||
|
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::v2::{InputPin, OutputPin},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::color::OctColor;
|
use crate::color::OctColor;
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
||||||
|
|
@ -48,7 +44,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
// Reset the device
|
// Reset the device
|
||||||
|
|
@ -81,7 +77,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = OctColor;
|
type DisplayColor = OctColor;
|
||||||
fn new(
|
fn new(
|
||||||
|
|
@ -205,7 +201,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,7 @@
|
||||||
//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/702def06bcb75983c98b0f9d25d43c552c248eb0/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_7in5.c)
|
//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/702def06bcb75983c98b0f9d25d43c552c248eb0/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_7in5.c)
|
||||||
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/702def06bcb75983c98b0f9d25d43c552c248eb0/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5.py)
|
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/702def06bcb75983c98b0f9d25d43c552c248eb0/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5.py)
|
||||||
|
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::{InputPin, OutputPin},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
||||||
|
|
@ -48,7 +44,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
// Reset the device
|
// Reset the device
|
||||||
|
|
@ -67,7 +63,7 @@ where
|
||||||
|
|
||||||
// Power on
|
// Power on
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
delay.try_delay_ms(5);
|
delay.delay_ms(5);
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// Set the clock frequency to 50Hz (default)
|
// Set the clock frequency to 50Hz (default)
|
||||||
|
|
@ -104,7 +100,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new(
|
fn new(
|
||||||
|
|
@ -235,7 +231,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,7 @@
|
||||||
//! - [Datasheet](https://www.waveshare.com/w/upload/2/27/7inch_HD_e-Paper_Specification.pdf)
|
//! - [Datasheet](https://www.waveshare.com/w/upload/2/27/7inch_HD_e-Paper_Specification.pdf)
|
||||||
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_HD.py)
|
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_HD.py)
|
||||||
//!
|
//!
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::v2::{InputPin, OutputPin},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
||||||
|
|
@ -51,7 +47,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
// Reset the device
|
// Reset the device
|
||||||
|
|
@ -104,7 +100,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new(
|
fn new(
|
||||||
|
|
@ -232,7 +228,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,7 @@
|
||||||
//! Revision V2 has been released on 2019.11, the resolution is upgraded to 800×480, from 640×384 of V1.
|
//! Revision V2 has been released on 2019.11, the resolution is upgraded to 800×480, from 640×384 of V1.
|
||||||
//! The hardware and interface of V2 are compatible with V1, however, the related software should be updated.
|
//! The hardware and interface of V2 are compatible with V1, however, the related software should be updated.
|
||||||
|
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::{InputPin, OutputPin},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
||||||
|
|
@ -52,7 +48,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
// Reset the device
|
// Reset the device
|
||||||
|
|
@ -86,7 +82,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new(
|
fn new(
|
||||||
|
|
@ -209,7 +205,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
use crate::traits::Command;
|
use crate::traits::Command;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// The Connection Interface of all (?) Waveshare EPD-Devices
|
/// The Connection Interface of all (?) Waveshare EPD-Devices
|
||||||
///
|
///
|
||||||
|
|
@ -29,7 +26,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
pub fn new(cs: CS, busy: BUSY, dc: DC, rst: RST) -> Self {
|
pub fn new(cs: CS, busy: BUSY, dc: DC, rst: RST) -> Self {
|
||||||
DisplayInterface {
|
DisplayInterface {
|
||||||
|
|
@ -47,7 +44,7 @@ where
|
||||||
/// Enables direct interaction with the device with the help of [data()](DisplayInterface::data())
|
/// Enables direct interaction with the device with the help of [data()](DisplayInterface::data())
|
||||||
pub(crate) fn cmd<T: Command>(&mut self, spi: &mut SPI, command: T) -> Result<(), SPI::Error> {
|
pub(crate) fn cmd<T: Command>(&mut self, spi: &mut SPI, command: T) -> Result<(), SPI::Error> {
|
||||||
// low for commands
|
// low for commands
|
||||||
let _ = self.dc.try_set_low();
|
let _ = self.dc.set_low();
|
||||||
|
|
||||||
// Transfer the command over spi
|
// Transfer the command over spi
|
||||||
self.write(spi, &[command.address()])
|
self.write(spi, &[command.address()])
|
||||||
|
|
@ -58,7 +55,7 @@ where
|
||||||
/// Enables direct interaction with the device with the help of [command()](Epd4in2::command())
|
/// Enables direct interaction with the device with the help of [command()](Epd4in2::command())
|
||||||
pub(crate) fn data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
pub(crate) fn data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
||||||
// high for data
|
// high for data
|
||||||
let _ = self.dc.try_set_high();
|
let _ = self.dc.set_high();
|
||||||
|
|
||||||
for val in data.iter().copied() {
|
for val in data.iter().copied() {
|
||||||
// Transfer data one u8 at a time over spi
|
// Transfer data one u8 at a time over spi
|
||||||
|
|
@ -91,7 +88,7 @@ where
|
||||||
repetitions: u32,
|
repetitions: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), SPI::Error> {
|
||||||
// high for data
|
// high for data
|
||||||
let _ = self.dc.try_set_high();
|
let _ = self.dc.set_high();
|
||||||
// Transfer data (u8) over spi
|
// Transfer data (u8) over spi
|
||||||
for _ in 0..repetitions {
|
for _ in 0..repetitions {
|
||||||
self.write(spi, &[val])?;
|
self.write(spi, &[val])?;
|
||||||
|
|
@ -102,21 +99,21 @@ where
|
||||||
// spi write helper/abstraction function
|
// spi write helper/abstraction function
|
||||||
fn write(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
fn write(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
||||||
// activate spi with cs low
|
// activate spi with cs low
|
||||||
let _ = self.cs.try_set_low();
|
let _ = self.cs.set_low();
|
||||||
|
|
||||||
// transfer spi data
|
// transfer spi data
|
||||||
// Be careful!! Linux has a default limit of 4096 bytes per spi transfer
|
// Be careful!! Linux has a default limit of 4096 bytes per spi transfer
|
||||||
// see https://raspberrypi.stackexchange.com/questions/65595/spi-transfer-fails-with-buffer-size-greater-than-4096
|
// see https://raspberrypi.stackexchange.com/questions/65595/spi-transfer-fails-with-buffer-size-greater-than-4096
|
||||||
if cfg!(target_os = "linux") {
|
if cfg!(target_os = "linux") {
|
||||||
for data_chunk in data.chunks(4096) {
|
for data_chunk in data.chunks(4096) {
|
||||||
spi.try_write(data_chunk)?;
|
spi.write(data_chunk)?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
spi.try_write(data)?;
|
spi.write(data)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// deactivate spi with cs high
|
// deactivate spi with cs high
|
||||||
let _ = self.cs.try_set_high();
|
let _ = self.cs.set_high();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -158,8 +155,8 @@ where
|
||||||
/// Most likely there was a mistake with the 2in9 busy connection
|
/// Most likely there was a mistake with the 2in9 busy connection
|
||||||
/// //TODO: use the #cfg feature to make this compile the right way for the certain types
|
/// //TODO: use the #cfg feature to make this compile the right way for the certain types
|
||||||
pub(crate) fn is_busy(&self, is_busy_low: bool) -> bool {
|
pub(crate) fn is_busy(&self, is_busy_low: bool) -> bool {
|
||||||
(is_busy_low && self.busy.try_is_low().unwrap_or(false))
|
(is_busy_low && self.busy.is_low().unwrap_or(false))
|
||||||
|| (!is_busy_low && self.busy.try_is_high().unwrap_or(false))
|
|| (!is_busy_low && self.busy.is_high().unwrap_or(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets the device.
|
/// Resets the device.
|
||||||
|
|
@ -169,15 +166,15 @@ where
|
||||||
/// The timing of keeping the reset pin low seems to be important and different per device.
|
/// The timing of keeping the reset pin low seems to be important and different per device.
|
||||||
/// Most displays seem to require keeping it low for 10ms, but the 7in5_v2 only seems to reset
|
/// Most displays seem to require keeping it low for 10ms, but the 7in5_v2 only seems to reset
|
||||||
/// properly with 2ms
|
/// properly with 2ms
|
||||||
pub(crate) fn reset(&mut self, delay: &mut DELAY, duration: u8) {
|
pub(crate) fn reset(&mut self, delay: &mut DELAY, duration: u32) {
|
||||||
let _ = self.rst.try_set_high();
|
let _ = self.rst.set_high();
|
||||||
delay.try_delay_ms(10);
|
delay.delay_ms(10);
|
||||||
|
|
||||||
let _ = self.rst.try_set_low();
|
let _ = self.rst.set_low();
|
||||||
delay.try_delay_ms(duration);
|
delay.delay_ms(duration);
|
||||||
let _ = self.rst.try_set_high();
|
let _ = self.rst.set_high();
|
||||||
//TODO: the upstream libraries always sleep for 200ms here
|
//TODO: the upstream libraries always sleep for 200ms here
|
||||||
// 10ms works fine with just for the 7in5_v2 but this needs to be validated for other devices
|
// 10ms works fine with just for the 7in5_v2 but this needs to be validated for other devices
|
||||||
delay.try_delay_ms(200);
|
delay.delay_ms(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,10 @@ pub mod prelude {
|
||||||
pub use crate::graphics::{Display, DisplayRotation, OctDisplay, TriDisplay};
|
pub use crate::graphics::{Display, DisplayRotation, OctDisplay, TriDisplay};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) mod eh_prelude {
|
||||||
|
pub(crate) use embedded_hal::{delay::blocking::DelayUs, spi::blocking::Write, digital::blocking::{InputPin, OutputPin}};
|
||||||
|
}
|
||||||
|
|
||||||
/// Computes the needed buffer length. Takes care of rounding up in case width
|
/// Computes the needed buffer length. Takes care of rounding up in case width
|
||||||
/// is not divisible by 8.
|
/// is not divisible by 8.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
use core::marker::Sized;
|
use core::marker::Sized;
|
||||||
use embedded_hal::{
|
use crate::eh_prelude::*;
|
||||||
blocking::{delay::*, spi::Write},
|
|
||||||
digital::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// All commands need to have this trait which gives the address of the command
|
/// All commands need to have this trait which gives the address of the command
|
||||||
/// which needs to be send via SPI with activated CommandsPin (Data/Command Pin in CommandMode)
|
/// which needs to be send via SPI with activated CommandsPin (Data/Command Pin in CommandMode)
|
||||||
|
|
@ -33,7 +30,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
/// This initialises the EPD and powers it up
|
/// This initialises the EPD and powers it up
|
||||||
///
|
///
|
||||||
|
|
@ -57,7 +54,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
/// Transmit data to the SRAM of the EPD
|
/// Transmit data to the SRAM of the EPD
|
||||||
///
|
///
|
||||||
|
|
@ -133,7 +130,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
/// The Color Type used by the Display
|
/// The Color Type used by the Display
|
||||||
type DisplayColor;
|
type DisplayColor;
|
||||||
|
|
@ -288,7 +285,7 @@ where
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayMs<u8>,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
/// Updates the old frame.
|
/// Updates the old frame.
|
||||||
fn update_old_frame(
|
fn update_old_frame(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue