switch_hal/input/mod.rs
1use crate::{ActiveHigh, ActiveLow, InputSwitch, Switch};
2use embedded_hal::digital::v2::InputPin;
3
4impl<T: InputPin> InputSwitch for Switch<T, ActiveHigh> {
5 type Error = <T as InputPin>::Error;
6
7 fn is_active(&self) -> Result<bool, Self::Error> {
8 self.pin.is_high()
9 }
10}
11
12impl<T: InputPin> InputSwitch for Switch<T, ActiveLow> {
13 type Error = <T as InputPin>::Error;
14
15 fn is_active(&self) -> Result<bool, Self::Error> {
16 self.pin.is_low()
17 }
18}