Why doesn't ExtiInput implement InputPin? #188
Unanswered
Kuerbiskakteen
asked this question in
Q&A
Replies: 1 comment
|
@Kuerbiskakteen A work around is writing a custom NewType that implements both traits. don't forget to also implement direct methods (constructor, etc...) struct MyInput<'d> (ExtiInput<'d>);
impl<'d> embedded_hal::digital::ErrorType for MyInput<'d> {
type Error = core::convert::Infallible;
}
impl<'d> embedded_hal::digital::InputPin for MyInput<'d> {
fn is_high(&mut self) -> Result<bool, Self::Error> {
Ok(self.0.is_high())
}
fn is_low(&mut self) -> Result<bool, Self::Error> {
Ok(self.0.is_low())
}
}
impl<'d> embedded_hal_async::digital::Wait for MyInput<'d> {
async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> {
Ok(self.0.wait_for_any_edge().await)
}
async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> {
Ok(self.0.wait_for_falling_edge().await)
}
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
Ok(self.0.wait_for_high().await)
}
async fn wait_for_low(&mut self) -> Result<(), Self::Error> {
Ok(self.0.wait_for_low().await)
}
async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> {
Ok(self.0.wait_for_rising_edge().await)
}
} |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The crate weact_studio_epd requires a pin that implements both InputPin + Wait. In ch32-hal, there is nothing that implements both, but ExtiInput has the required method. Is there any reason why it doesn't?
All reactions