Closed
Description
What are the practical use cases for a pin that you can only toggle, and is there hardware out there with pins that you can only toggle but not read the current state of?
I can't think of a use case for the trait beyond blinking an LED or something and even then it shouldn't need to be a separate trait. I think it should rather be a method with a default impl on StatefulOutputPin
to avoid having to implement it separately in every HAL:
pub trait StatefulOutputPin: OutputPin {
// ...
fn toggle(&mut self) -> Result<(), Self::Error> {
let new_state = self.is_set_low()?.into();
self.set_state(new_state)
}
}
The default implementation could of course be overridden on hardware where there is a more efficient way to toggle a pin.
Metadata
Metadata
Assignees
Labels
No labels