Change relay number to needed setting value
This commit is contained in:
parent
c3b185b592
commit
e9ea0b625d
1 changed files with 3 additions and 11 deletions
|
@ -11,7 +11,7 @@ use crate::driver::Driver;
|
|||
pub struct Relay {
|
||||
pub driver: Driver,
|
||||
pub name: String,
|
||||
pub number: Option<i64>,
|
||||
pub number: i64,
|
||||
pub pin: u8,
|
||||
pub inverted: bool,
|
||||
pub pulse: Option<u64>,
|
||||
|
@ -58,20 +58,12 @@ impl Default for Relay {
|
|||
}
|
||||
|
||||
pub fn init() -> Result<Settings, EmgauwaError> {
|
||||
let mut settings: Settings = settings::load("controller", "CONTROLLER")?;
|
||||
|
||||
for (num, relay) in settings.relays.iter_mut().enumerate() {
|
||||
if relay.number.is_none() {
|
||||
relay.number = Some(num as i64);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(settings)
|
||||
settings::load("controller", "CONTROLLER")
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
pub fn get_relay(&self, number: i64) -> Option<&Relay> {
|
||||
self.relays.iter().find(|r| r.number == Some(number))
|
||||
self.relays.iter().find(|r| r.number == number)
|
||||
}
|
||||
|
||||
pub fn relays_make_drivers(
|
||||
|
|
Loading…
Reference in a new issue