pub struct LatchRelay<I2C> { /* private fields */ }Expand description
Driver for the Modulino Latch Relay module.
A latching relay maintains its state (on/off) even when power is removed.
§Example
ⓘ
use modulino::LatchRelay;
let mut relay = LatchRelay::new(i2c)?;
// Turn on the relay
relay.on()?;
// Check state
if relay.is_on()? == Some(true) {
println!("Relay is ON");
}
// Turn off the relay
relay.off()?;Implementations§
Source§impl<I2C, E> LatchRelay<I2C>where
I2C: I2c<Error = E>,
impl<I2C, E> LatchRelay<I2C>where
I2C: I2c<Error = E>,
Sourcepub fn new(i2c: I2C) -> Result<Self, E>
pub fn new(i2c: I2C) -> Result<Self, E>
Create a new LatchRelay instance with the default address.
Sourcepub fn new_with_address(i2c: I2C, address: u8) -> Result<Self, E>
pub fn new_with_address(i2c: I2C, address: u8) -> Result<Self, E>
Create a new LatchRelay instance with a custom address.
Auto Trait Implementations§
impl<I2C> Freeze for LatchRelay<I2C>where
I2C: Freeze,
impl<I2C> RefUnwindSafe for LatchRelay<I2C>where
I2C: RefUnwindSafe,
impl<I2C> Send for LatchRelay<I2C>where
I2C: Send,
impl<I2C> Sync for LatchRelay<I2C>where
I2C: Sync,
impl<I2C> Unpin for LatchRelay<I2C>where
I2C: Unpin,
impl<I2C> UnwindSafe for LatchRelay<I2C>where
I2C: 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