diff --git a/Cargo.lock b/Cargo.lock index 483b6ac..2056702 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,7 +89,7 @@ dependencies = [ [[package]] name = "bme680-json" -version = "1.0.0" +version = "1.0.2" dependencies = [ "anyhow", "bme680", diff --git a/Cargo.toml b/Cargo.toml index ea9ec14..59f383e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bme680-json" -version = "1.0.1" +version = "1.0.2" edition = "2021" [dependencies] diff --git a/src/main.rs b/src/main.rs index ca9ba69..82ab1a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,6 +22,10 @@ struct Args { /// I2C address to use #[arg(long, default_value_t = String::from("/dev/i2c-1"))] i2c_address: String, + + /// Delay reading by the specified amount in milliseconds. + #[arg(long, default_value_t = 1000)] + delay_before_read: u32 } fn main() -> Result<(), anyhow::Error> { @@ -43,7 +47,7 @@ fn main() -> Result<(), anyhow::Error> { dev.set_sensor_settings(&mut delay, &settings)?; dev.set_sensor_mode(&mut delay, PowerMode::ForcedMode)?; - Delay {}.delay_ms(5000u32); + Delay {}.delay_ms(args.delay_before_read); let (data, _) = dev.get_measurement(&mut delay)?; let serialized = serde_json::to_string(&JsonData{ temperature: data.temperature_celsius(),