Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to embedded-hal 1.0 #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ denon = []
remotes = []

[dependencies]
embedded-hal = {version = "0.2.4", features = ["unproven"], optional = true}
embedded-hal = { version = "1.0", optional = true }
defmt = { version = "0.3", optional = true }
log = { version = "0.4", optional = true }
fugit = { version = "0.3.5", optional = true }

[dev-dependencies]
dummy-pin = "0.1.1"
dummy-pin = "1.0.0"
4 changes: 2 additions & 2 deletions src/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
//!
//! #### Polled example
//! ```
//! use embedded_hal::digital::v2::InputPin;
//! use embedded_hal::digital::InputPin;
//! use dummy_pin::DummyPin;
//! use infrared::protocol::Nec;
//!
Expand Down Expand Up @@ -111,7 +111,7 @@
use core::marker::PhantomData;

#[cfg(feature = "embedded-hal")]
use embedded_hal::digital::v2::InputPin;
use embedded_hal::digital::InputPin;

use crate::{receiver::time::InfraMonotonic, Protocol};

Expand Down
2 changes: 1 addition & 1 deletion src/receiver/builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::marker::PhantomData;

#[cfg(feature = "embedded-hal")]
use embedded_hal::digital::v2::InputPin;
use embedded_hal::digital::InputPin;

#[cfg(feature = "denon")]
use crate::protocol::Denon;
Expand Down
2 changes: 1 addition & 1 deletion src/receiver/multi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "embedded-hal")]
use embedded_hal::digital::v2::InputPin;
use embedded_hal::digital::InputPin;

use crate::{
cmd::AnyCommand,
Expand Down
2 changes: 1 addition & 1 deletion src/receiver/ppoll.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::marker::PhantomData;

#[cfg(feature = "embedded")]
use embedded_hal::digital::v2::InputPin;
use embedded_hal::digital::InputPin;

use crate::{
receiver::{DecoderBuilder, DecodingError, Error, NoPin, ProtocolDecoder},
Expand Down
2 changes: 1 addition & 1 deletion src/sender/hal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct Sender<PwmPin, const FREQ: u32, const BUFSIZE: usize> {

impl<PwmPin, PwmDuty, const F: u32, const S: usize> Sender<PwmPin, F, S>
where
PwmPin: embedded_hal::PwmPin<Duty = PwmDuty>,
PwmPin: embedded_hal::pwm::SetDutyCycle,
{
pub fn new(pin: PwmPin) -> Self {
Self {
Expand Down
4 changes: 0 additions & 4 deletions src/sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
use crate::protocol::Protocol;

mod buffer;
#[cfg(feature = "embedded-hal")]
mod hal;
mod senders;

pub use buffer::*;
#[cfg(feature = "embedded-hal")]
pub use hal::*;
pub use senders::*;

pub trait ProtocolEncoder<const FREQ: u32>: Protocol {
Expand Down
10 changes: 6 additions & 4 deletions tests/builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use embedded_hal::digital::v2::InputPin;
use std::convert::Infallible;
use embedded_hal::digital::{ErrorType, InputPin};

#[cfg(feature = "rc5")]
#[test]
Expand Down Expand Up @@ -31,14 +32,15 @@ fn receiver_remote() {

struct DummyEmbeddedHalPin;

impl ErrorType for DummyEmbeddedHalPin { type Error = Infallible; }

impl InputPin for DummyEmbeddedHalPin {
type Error = ();

fn is_high(&self) -> Result<bool, Self::Error> {
fn is_high(&mut self) -> Result<bool, Self::Error> {
Ok(true)
}

fn is_low(&self) -> Result<bool, Self::Error> {
fn is_low(&mut self) -> Result<bool, Self::Error> {
Ok(false)
}
}
Loading