[−][src]Module embedded_hal::digital::toggleable
If you can read and write the output state, a pin is toggleable by software.
use embedded_hal::digital::{OutputPin, StatefulOutputPin, ToggleableOutputPin}; use embedded_hal::digital::toggleable; /// A virtual output pin that exists purely in software struct MyPin { state: bool } impl OutputPin for MyPin { fn set_low(&mut self) { self.state = false; } fn set_high(&mut self) { self.state = true; } } impl StatefulOutputPin for MyPin { fn is_set_low(&self) -> bool { !self.state } fn is_set_high(&self) -> bool { self.state } } /// Opt-in to the software implementation. impl toggleable::Default for MyPin {} let mut pin = MyPin { state: false }; pin.toggle(); assert!(pin.is_set_high()); pin.toggle(); assert!(pin.is_set_low());
Traits
Default | Software-driven |