forked from gkaklas/labadoor
Add configuration options for GPIO
This commit is contained in:
parent
413568af5e
commit
c8e412fa34
4 changed files with 34 additions and 9 deletions
|
@ -4,3 +4,9 @@ token = ""
|
|||
[matrix]
|
||||
username = ""
|
||||
password = ""
|
||||
|
||||
[gpio]
|
||||
device = ""
|
||||
pin = 1
|
||||
active_low = false
|
||||
active_time = 2000
|
||||
|
|
|
@ -16,7 +16,7 @@ pub enum Command {
|
|||
#[cfg(feature = "csv")]
|
||||
CSV,
|
||||
#[cfg(feature = "gpio")]
|
||||
GPIO,
|
||||
GPIO(GPIO),
|
||||
}
|
||||
|
||||
#[cfg(feature = "telegram")]
|
||||
|
@ -35,6 +35,19 @@ pub struct Matrix {
|
|||
pub password: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "gpio")]
|
||||
#[derive(Deserialize, Parser, Debug)]
|
||||
pub struct GPIO {
|
||||
#[clap(short, long)]
|
||||
pub device: Option<String>,
|
||||
#[clap(short, long)]
|
||||
pub pin: Option<u8>,
|
||||
#[clap(short, long)]
|
||||
pub active_low: Option<bool>,
|
||||
#[clap(short = 't', long)]
|
||||
pub active_time: Option<u32>,
|
||||
}
|
||||
|
||||
pub fn parse() -> Cli {
|
||||
Cli::parse()
|
||||
}
|
||||
|
|
|
@ -23,8 +23,14 @@ fn main() {
|
|||
labadoor_csv::csv();
|
||||
}
|
||||
#[cfg(feature = "gpio")]
|
||||
cli::Command::GPIO => {
|
||||
labadoor_gpio::gpio();
|
||||
cli::Command::GPIO(_) => {
|
||||
let gpio = config.get::<cli::GPIO>("gpio").unwrap();
|
||||
labadoor_gpio::gpio(
|
||||
gpio.device.unwrap(),
|
||||
gpio.pin.unwrap(),
|
||||
gpio.active_low.unwrap(),
|
||||
gpio.active_time.unwrap(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue