[−][src]Trait switch_hal::InputSwitch
Represents an input switch, such as a button or a switch
Associated Types
type Error
Required methods
fn is_active(&self) -> Result<bool, Self::Error>
Returns true if the swich has been activated, otherwise false i.e. if a button is currently pressed, returns true
Examples
use switch_hal::{ActiveLow, InputSwitch, OutputSwitch, Switch}; let button = Switch::<_, ActiveLow>::new(pin); match button.is_active() { Ok(true) => { status_led.on().ok(); } Ok(false) => { status_led.off().ok(); } Err(_) => { panic!("Failed to read button state"); } }