Add relay pulse functionality
This commit is contained in:
parent
e2f3d7b82a
commit
61a3c6093b
14 changed files with 201 additions and 13 deletions
emgauwa-controller/src
|
@ -13,6 +13,7 @@ pub struct Relay {
|
|||
pub number: Option<i64>,
|
||||
pub pin: u8,
|
||||
pub inverted: bool,
|
||||
pub pulse: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
|
@ -50,6 +51,7 @@ impl Default for Relay {
|
|||
name: String::from("Relay"),
|
||||
pin: 0,
|
||||
inverted: false,
|
||||
pulse: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,3 +67,9 @@ pub fn init() -> Result<Settings, EmgauwaError> {
|
|||
|
||||
Ok(settings)
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
pub fn get_relay(&self, number: i64) -> Option<&Relay> {
|
||||
self.relays.iter().find(|r| r.number == Some(number))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue