pub struct FlexLed<P> { /* private fields */ }Expand description
LED with runtime-determined polarity.
Unlike Led which bakes polarity into the type, FlexLed stores it as a
PolarityMode value. Useful when the polarity is read from configuration
at runtime rather than known at compile time. Each operation incurs one
extra match vs Led — negligible on Cortex-M.
§Examples
ⓘ
use status_led::{FlexLed, PolarityMode};
let pol = if config.active_low {
PolarityMode::ActiveLow
} else {
PolarityMode::ActiveHigh
};
let mut led = FlexLed::new(pin, pol).unwrap();
led.on().unwrap();Implementations§
Source§impl<P> FlexLed<P>
impl<P> FlexLed<P>
Sourcepub fn from_pin(pin: P, polarity: PolarityMode) -> Self
pub fn from_pin(pin: P, polarity: PolarityMode) -> Self
Build from an already-configured pin without changing its level.
Source§impl<P: OutputPin> FlexLed<P>
impl<P: OutputPin> FlexLed<P>
Sourcepub fn new(pin: P, polarity: PolarityMode) -> Result<Self, P::Error>
pub fn new(pin: P, polarity: PolarityMode) -> Result<Self, P::Error>
Build and force the pin to the logical OFF state.
Source§impl<P: StatefulOutputPin> FlexLed<P>
impl<P: StatefulOutputPin> FlexLed<P>
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for FlexLed<P>where
P: Freeze,
impl<P> RefUnwindSafe for FlexLed<P>where
P: RefUnwindSafe,
impl<P> Send for FlexLed<P>where
P: Send,
impl<P> Sync for FlexLed<P>where
P: Sync,
impl<P> Unpin for FlexLed<P>where
P: Unpin,
impl<P> UnsafeUnpin for FlexLed<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for FlexLed<P>where
P: UnwindSafe,
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