pub enum Polarity {
ActiveHigh,
ActiveLow,
}Expand description
Whether a signal is asserted by a high or a low physical level.
Active-low wiring is everywhere in cheap hardware: a button to ground with a pull-up
reads Level::Low when pressed, and many relay boards energise when their input is
driven low. This type maps between the logical idea of “asserted” and the physical
Level so the mapping lives in one place instead of in scattered inversions.
§Examples
use pamoja_gpio::pin::{Level, Polarity};
// An active-low relay: asserting it (switching the relay on) drives the pin low.
let relay = Polarity::ActiveLow;
assert_eq!(relay.level(true), Level::Low);
assert_eq!(relay.level(false), Level::High);
assert!(relay.is_asserted(Level::Low));Variants§
ActiveHigh
A high level means asserted (the direct mapping).
ActiveLow
A low level means asserted (the inverted mapping).
Implementations§
Trait Implementations§
impl Copy for Polarity
impl Eq for Polarity
impl StructuralPartialEq for Polarity
Auto Trait Implementations§
impl Freeze for Polarity
impl RefUnwindSafe for Polarity
impl Send for Polarity
impl Sync for Polarity
impl Unpin for Polarity
impl UnsafeUnpin for Polarity
impl UnwindSafe for Polarity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more