From 4b87e3c2f75cfb42ac7a162f6c58f8596a2101ca Mon Sep 17 00:00:00 2001 From: marcelbuesing Date: Tue, 16 Nov 2021 15:39:57 +0100 Subject: [PATCH] Migrate to embedded-hal=1.0.0-alpha.5 --- Cargo.toml | 8 ++++---- src/lib.rs | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8fc0649..658567c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,16 +14,16 @@ maintenance = { status = "passively-maintained" } [dependencies] bitflags = "1.2" -embedded-hal = "0.2" +embedded-hal = "=1.0.0-alpha.5" log = "0.4" [dev-dependencies] -env_logger = "0.8" +env_logger = "0.9" futures = { version = "0.3" } -i2cdev = "0.4" +i2cdev = "0.5" influx_db_client = { version = "0.5", default-features= false, features = ["rustls-tls"] } tokio = {version = "1.5", features = ["full"] } url = "2.1" [target.'cfg(target_os = "linux")'.dev-dependencies] -linux-embedded-hal = "0.3" \ No newline at end of file +linux-embedded-hal = "0.4.0-alpha.1" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index e246a8c..45320b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -93,8 +93,8 @@ mod calc; mod settings; use crate::calc::Calc; -use crate::hal::blocking::delay::DelayMs; -use crate::hal::blocking::i2c::{Read, Write}; +use crate::hal::delay::blocking::DelayMs; +use crate::hal::i2c::blocking::{Read, Write}; use core::time::Duration; use core::{marker::PhantomData, result}; @@ -172,6 +172,7 @@ pub enum Error { /// I2CWrite(W), I2CRead(R), + Delay, /// /// aka BME680_E_DEV_NOT_FOUND /// @@ -459,7 +460,9 @@ where i2c.write(dev_id.addr(), &tmp_buff) .map_err(Error::I2CWrite)?; - delay.delay_ms(BME680_RESET_PERIOD); + delay + .delay_ms(BME680_RESET_PERIOD) + .map_err(|_| Error::Delay)?; Ok(()) } @@ -725,7 +728,9 @@ where tmp_pow_mode &= !BME680_MODE_MSK; debug!("Setting to sleep tmp_pow_mode: {}", tmp_pow_mode); self.bme680_set_regs(&[(BME680_CONF_T_P_MODE_ADDR, tmp_pow_mode)])?; - delay.delay_ms(BME680_POLL_PERIOD_MS); + delay + .delay_ms(BME680_POLL_PERIOD_MS) + .map_err(|_| Error::Delay)?; } else { // TODO do while in Rust? break; @@ -990,7 +995,9 @@ where return Ok((data, FieldDataCondition::NewData)); } - delay.delay_ms(BME680_POLL_PERIOD_MS); + delay + .delay_ms(BME680_POLL_PERIOD_MS) + .map_err(|_| Error::Delay)?; } Ok((data, FieldDataCondition::Unchanged)) }