From 53b9ba375c223ae892904c8c6adadd1f01855bb5 Mon Sep 17 00:00:00 2001 From: Krystian Wojtas Date: Sun, 16 Feb 2020 13:45:45 +0100 Subject: [PATCH 1/2] [no_std] should be declared in binary crate root instead of library. Otherwise it cannot be used by std projects --- src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2f5667a..70a408d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,10 +5,6 @@ //! //! [`embedded-hal`]: https://docs.rs/embedded-hal/ -#![deny(missing_docs)] -#![deny(warnings)] -#![no_std] - use core::cmp; use embedded_hal::blocking::i2c::{Read, Write, WriteRead}; From 0446baf32bf6a90c2a408562c0659ed12d9d2955 Mon Sep 17 00:00:00 2001 From: Krystian Wojtas Date: Sun, 16 Feb 2020 14:27:15 +0100 Subject: [PATCH 2/2] allow unused functions to not generate warnings --- src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 70a408d..89aff6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,6 +45,7 @@ pub enum Error { } /// Firmware Version +#[allow(dead_code)] pub enum FirmwareVersion { /// Version 1.0 V1_0, @@ -94,6 +95,7 @@ pub enum HeaterLevel { impl HeaterLevel { /// Get heater control register value. + #[allow(dead_code)] pub fn value(self) -> u8 { self as u8 } @@ -126,6 +128,7 @@ pub enum Resolution { impl Resolution { /// Get register value. + #[allow(dead_code)] pub fn res(self) -> u8 { self as u8 } @@ -148,6 +151,7 @@ where /// Starts a humidity measurement and waits for it to finish before /// returning the measured value together with the temperature without /// doing a separate temperature measurement. + #[allow(dead_code)] pub fn humidity_temperature(&mut self) -> Result<(u16, i16), Error> { let humidity = self.humidity()?; self.command(Command::ReadTempPostHumMeasurement)?; @@ -198,12 +202,14 @@ where } /// Issues a software reset. + #[allow(dead_code)] pub fn reset(&mut self) -> Result<(), Error> { self.command(Command::Reset)?; Ok(()) } /// Sets the measurement resolution. + #[allow(dead_code)] pub fn set_resolution(&mut self, res: Resolution) -> Result<(), E> { let reg = self.read_user_reg()? & 0x7E | res.res(); self.i2c @@ -211,6 +217,7 @@ where } /// Returns the current measurement resolution. + #[allow(dead_code)] pub fn get_resolution(&mut self) -> Result { let reg = self.read_user_reg()?; @@ -224,17 +231,20 @@ where } /// Sets the heater level. + #[allow(dead_code)] pub fn set_heater_level(&mut self, level: HeaterLevel) -> Result<(), E> { self.i2c .write(ADDRESS, &[Command::ReadHeaterCtrlReg.cmd(), level.value()]) } /// Enables the heater. + #[allow(dead_code)] pub fn enable_heater(&mut self) -> Result<(), E> { self.control_heater(0x04) } /// Disables the heater. + #[allow(dead_code)] pub fn disable_heater(&mut self) -> Result<(), E> { self.control_heater(0x00) } @@ -248,6 +258,7 @@ where /// Returns the VDD Status. If the operating voltage drops below 1.9 V, this /// will return `false`. If the operating voltage drops below 1.8 V, the device /// will no longer operate correctly. + #[allow(dead_code)] pub fn vdd_status(&mut self) -> Result { let reg = self.read_user_reg()?; match reg & 0x40 { @@ -277,6 +288,7 @@ where /// - `0x14 = 20`: Si7020 /// - `0x15 = 21`: Si7021 /// - `0x32 = 50`: HTU21D/SHT21 + #[allow(dead_code)] pub fn serial(&mut self) -> Result<[u8; 8], Error> { let mut serial = [0u8; 8]; let mut buffer = [0u8; 8]; @@ -303,6 +315,7 @@ where /// /// - `0xFF`: Firmware version 1.0 /// - `0x20`: Firmware version 2.0 + #[allow(dead_code)] pub fn firmware_rev(&mut self) -> Result { let mut buffer = [0]; self.i2c.write(ADDRESS, &[0x84, 0xB8])?;