refactor: fix clippy hints
This commit is contained in:
parent
cf9b0fbdd0
commit
35c2adef92
3 changed files with 6 additions and 11 deletions
|
@ -39,7 +39,7 @@ impl Calculation {
|
||||||
let mut factor: u8 = 0u8;
|
let mut factor: u8 = 0u8;
|
||||||
const MILLIS_PER_SEC: u64 = 1_000;
|
const MILLIS_PER_SEC: u64 = 1_000;
|
||||||
const NANOS_PER_MILLI: u64 = 1_000_000;
|
const NANOS_PER_MILLI: u64 = 1_000_000;
|
||||||
let mut dur = (duration.as_secs() as u64 * MILLIS_PER_SEC)
|
let mut dur = (duration.as_secs() * MILLIS_PER_SEC)
|
||||||
+ (duration.subsec_nanos() as u64 / NANOS_PER_MILLI);
|
+ (duration.subsec_nanos() as u64 / NANOS_PER_MILLI);
|
||||||
if dur as i32 >= 0xfc0i32 {
|
if dur as i32 >= 0xfc0i32 {
|
||||||
0xffu8 // Max duration
|
0xffu8 // Max duration
|
||||||
|
|
11
src/i2c.rs
11
src/i2c.rs
|
@ -5,9 +5,10 @@ use embedded_hal::i2c::I2c;
|
||||||
///
|
///
|
||||||
/// Represents the I2C address of the BME680 Sensor.
|
/// Represents the I2C address of the BME680 Sensor.
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy, Default)]
|
||||||
pub enum Address {
|
pub enum Address {
|
||||||
/// Primary Address 0x76
|
/// Primary Address 0x76
|
||||||
|
#[default]
|
||||||
Primary,
|
Primary,
|
||||||
/// Secondary Address 0x77
|
/// Secondary Address 0x77
|
||||||
Secondary,
|
Secondary,
|
||||||
|
@ -25,12 +26,6 @@ impl Address {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Address {
|
|
||||||
fn default() -> Address {
|
|
||||||
Address::Primary
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// I2CUtility is a simple wrapper over the I2c trait to make reading and writing data easier.
|
/// I2CUtility is a simple wrapper over the I2c trait to make reading and writing data easier.
|
||||||
pub(crate) struct I2CUtility {}
|
pub(crate) struct I2CUtility {}
|
||||||
|
|
||||||
|
@ -77,7 +72,7 @@ impl I2CUtility {
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
) -> Result<(), Bme680Error> {
|
) -> Result<(), Bme680Error> {
|
||||||
i2c_handle
|
i2c_handle
|
||||||
.write(device_address, &buffer)
|
.write(device_address, buffer)
|
||||||
.map_err(|_e| I2CWrite)
|
.map_err(|_e| I2CWrite)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,7 +415,7 @@ where
|
||||||
|
|
||||||
/// Sets the sensor registers.
|
/// Sets the sensor registers.
|
||||||
fn bme680_set_registers(&mut self, registers: &[(u8, u8)]) -> Result<(), Bme680Error> {
|
fn bme680_set_registers(&mut self, registers: &[(u8, u8)]) -> Result<(), Bme680Error> {
|
||||||
if registers.is_empty() || registers.len() > (BME680_TMP_BUFFER_LENGTH / 2) as usize {
|
if registers.is_empty() || registers.len() > (BME680_TMP_BUFFER_LENGTH / 2) {
|
||||||
return Err(Bme680Error::InvalidLength);
|
return Err(Bme680Error::InvalidLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +730,7 @@ where
|
||||||
duration += sensor_settings
|
duration += sensor_settings
|
||||||
.gas_settings
|
.gas_settings
|
||||||
.heater_duration
|
.heater_duration
|
||||||
.unwrap_or(Duration::default());
|
.unwrap_or_default();
|
||||||
}
|
}
|
||||||
Ok(duration)
|
Ok(duration)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue