Use embedded_hal::digital::v2 (v1 is deprecated)
parent
636b31437a
commit
a9f27e51ae
|
|
@ -36,4 +36,4 @@ version = "0.5.2"
|
||||||
|
|
||||||
[dependencies.embedded-hal]
|
[dependencies.embedded-hal]
|
||||||
features = ["unproven"]
|
features = ["unproven"]
|
||||||
version = "0.2.1"
|
version = "0.2.3"
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ const IS_BUSY_LOW: bool = false;
|
||||||
|
|
||||||
use embedded_hal::{
|
use embedded_hal::{
|
||||||
blocking::{delay::*, spi::Write},
|
blocking::{delay::*, spi::Write},
|
||||||
digital::*,
|
digital::v2::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::type_a::{
|
use crate::type_a::{
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use embedded_hal::{
|
use embedded_hal::{
|
||||||
blocking::{delay::*, spi::Write},
|
blocking::{delay::*, spi::Write},
|
||||||
digital::*,
|
digital::v2::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ const IS_BUSY_LOW: bool = false;
|
||||||
|
|
||||||
use embedded_hal::{
|
use embedded_hal::{
|
||||||
blocking::{delay::*, spi::Write},
|
blocking::{delay::*, spi::Write},
|
||||||
digital::*,
|
digital::v2::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::type_a::{
|
use crate::type_a::{
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
use embedded_hal::{
|
use embedded_hal::{
|
||||||
blocking::{delay::*, spi::Write},
|
blocking::{delay::*, spi::Write},
|
||||||
digital::*,
|
digital::v2::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
use embedded_hal::{
|
use embedded_hal::{
|
||||||
blocking::{delay::*, spi::Write},
|
blocking::{delay::*, spi::Write},
|
||||||
digital::v1::{InputPin, OutputPin},
|
digital::v2::{InputPin, OutputPin},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::traits::Command;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use embedded_hal::{
|
use embedded_hal::{
|
||||||
blocking::{delay::*, spi::Write},
|
blocking::{delay::*, spi::Write},
|
||||||
digital::*,
|
digital::v2::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The Connection Interface of all (?) Waveshare EPD-Devices
|
/// The Connection Interface of all (?) Waveshare EPD-Devices
|
||||||
|
|
@ -43,7 +43,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
|
||||||
self.dc.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()])
|
||||||
|
|
@ -54,7 +54,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
|
||||||
self.dc.set_high();
|
let _ = self.dc.set_high();
|
||||||
|
|
||||||
// Transfer data (u8-array) over spi
|
// Transfer data (u8-array) over spi
|
||||||
self.write(spi, data)
|
self.write(spi, data)
|
||||||
|
|
@ -83,7 +83,7 @@ where
|
||||||
repetitions: u32,
|
repetitions: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), SPI::Error> {
|
||||||
// high for data
|
// high for data
|
||||||
self.dc.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])?;
|
||||||
|
|
@ -94,7 +94,7 @@ 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
|
||||||
self.cs.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
|
||||||
|
|
@ -108,7 +108,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// deativate spi with cs high
|
// deativate spi with cs high
|
||||||
self.cs.set_high();
|
let _ = self.cs.set_high();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +138,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if device is still busy
|
/// Checks if device is still busy
|
||||||
///
|
///
|
||||||
/// This is normally handled by the more complicated commands themselves,
|
/// This is normally handled by the more complicated commands themselves,
|
||||||
/// but in the case you send data and commands directly you might need to check
|
/// but in the case you send data and commands directly you might need to check
|
||||||
/// if the device is still busy
|
/// if the device is still busy
|
||||||
|
|
@ -151,7 +151,7 @@ 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.is_low()) || (!is_busy_low && self.busy.is_high())
|
(is_busy_low && self.busy.is_low().unwrap_or(false)) || (!is_busy_low && self.busy.is_high().unwrap_or(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets the device.
|
/// Resets the device.
|
||||||
|
|
@ -160,10 +160,10 @@ where
|
||||||
///
|
///
|
||||||
/// TODO: Takes at least 400ms of delay alone, can it be shortened?
|
/// TODO: Takes at least 400ms of delay alone, can it be shortened?
|
||||||
pub(crate) fn reset<DELAY: DelayMs<u8>>(&mut self, delay: &mut DELAY) {
|
pub(crate) fn reset<DELAY: DelayMs<u8>>(&mut self, delay: &mut DELAY) {
|
||||||
self.rst.set_low();
|
let _ = self.rst.set_low();
|
||||||
//TODO: why 200ms? (besides being in the arduino version)
|
//TODO: why 200ms? (besides being in the arduino version)
|
||||||
delay.delay_ms(200);
|
delay.delay_ms(200);
|
||||||
self.rst.set_high();
|
let _ = self.rst.set_high();
|
||||||
//TODO: same as 3 lines above
|
//TODO: same as 3 lines above
|
||||||
delay.delay_ms(200);
|
delay.delay_ms(200);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::color::Color;
|
||||||
use core::marker::Sized;
|
use core::marker::Sized;
|
||||||
use embedded_hal::{
|
use embedded_hal::{
|
||||||
blocking::{delay::*, spi::Write},
|
blocking::{delay::*, spi::Write},
|
||||||
digital::*,
|
digital::v2::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue