add delay param
This commit is contained in:
parent
ddbd11561a
commit
02f80c2439
3 changed files with 7 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -89,7 +89,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "bme680-json"
|
||||
version = "1.0.0"
|
||||
version = "1.0.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bme680",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "bme680-json"
|
||||
version = "1.0.1"
|
||||
version = "1.0.2"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in a new issue