From 24389f4e69de5f7d332504d70b9fc64d3301b668 Mon Sep 17 00:00:00 2001 From: Thomas Riedler <117628110+tomried@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:53:47 +0200 Subject: [PATCH] Update to embedded-hal 1.0.0 (#44) --- Cargo.toml | 4 ++-- src/display.rs | 16 ++++++++-------- src/i2c.rs | 9 ++++----- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8b05ed3..ea582cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,9 +12,9 @@ readme = "README.md" exclude = ["media/*", "references/*"] [dependencies] -embedded-hal = "0.2.3" +embedded-hal = "1.0.0" ufmt = { version = "0.1.0", optional = true } -port-expander = { version = "0.3", optional = true } +port-expander = { version = "0.6.2", optional = true } shared-bus = "0.2" [features] diff --git a/src/display.rs b/src/display.rs index 0f919db..5e56e16 100644 --- a/src/display.rs +++ b/src/display.rs @@ -1,6 +1,6 @@ use crate::Error; -use embedded_hal::blocking::delay::DelayUs; -use embedded_hal::digital::v2::OutputPin; +use embedded_hal::delay::DelayNs; +use embedded_hal::digital::OutputPin; #[repr(u8)] #[allow(dead_code)] @@ -139,8 +139,8 @@ const DEFAULT_DISPLAY_FUNC: u8 = Mode::FourBits as u8 | Lines::OneLine as u8 | S const DEFAULT_DISPLAY_CTRL: u8 = Display::On as u8 | Cursor::Off as u8 | Blink::Off as u8; const DEFAULT_DISPLAY_MODE: u8 = Layout::LeftToRight as u8 | AutoScroll::Off as u8; -const CMD_DELAY: u16 = 3500; -const CHR_DELAY: u16 = 450; +const CMD_DELAY: u32 = 3500; +const CHR_DELAY: u32 = 450; const RS: u8 = 0; const EN: u8 = 1; @@ -162,7 +162,7 @@ const A: u8 = 11; pub struct LcdDisplay where T: OutputPin + Sized, - D: DelayUs + Sized, + D: DelayNs + Sized, { pins: [Option; 12], display_func: u8, @@ -176,7 +176,7 @@ where impl LcdDisplay where T: OutputPin + Sized, - D: DelayUs + Sized, + D: DelayNs + Sized, { /// Create a new instance of the LcdDisplay /// @@ -464,7 +464,7 @@ where /// .with_reliable_init(10000) /// .build(); /// ``` - pub fn with_reliable_init(mut self, delay_toggle: u16) -> Self { + pub fn with_reliable_init(mut self, delay_toggle: u32) -> Self { if self.display_ctrl == Display::On as u8 { for _ in 0..3 { self.delay.delay_us(delay_toggle); @@ -1253,7 +1253,7 @@ where impl ufmt::uWrite for LcdDisplay where T: OutputPin + Sized, - D: DelayUs + Sized, + D: DelayNs + Sized, { type Error = core::convert::Infallible; diff --git a/src/i2c.rs b/src/i2c.rs index 2e42007..3d6a70f 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -2,14 +2,13 @@ use crate::LcdDisplay; use core::fmt::Debug; -use embedded_hal::blocking::delay::DelayUs; -use port_expander::{dev::pcf8574, mode::QuasiBidirectional, I2cBus, Pcf8574, Pcf8574a, Pin}; -use shared_bus::BusMutex; +use embedded_hal::delay::DelayNs; +use port_expander::{dev::pcf8574, mode::QuasiBidirectional, I2cBus, Pcf8574, Pcf8574a, Pin, PortMutex}; impl<'a, D, M, I2C> LcdDisplay, D> where - D: DelayUs + Sized, - M: BusMutex>, + D: DelayNs + Sized, + M: PortMutex>, I2C: I2cBus, ::BusError: Debug, {