Replace run_gas u8 with boolean
This commit is contained in:
parent
dd05721aa3
commit
cce7d4c65c
3 changed files with 11 additions and 8 deletions
|
@ -29,7 +29,7 @@ fn main() -> result::Result<
|
|||
sensor_settings.tph_sett.os_temp = Some(OversamplingSetting::OS8x);
|
||||
sensor_settings.tph_sett.filter = Some(2);
|
||||
|
||||
sensor_settings.gas_sett.run_gas = Some(0x01);
|
||||
sensor_settings.gas_sett.run_gas_measurement = true;
|
||||
sensor_settings.gas_sett.heatr_dur = Some(Duration::from_millis(1500));
|
||||
sensor_settings.gas_sett.heatr_temp = Some(320);
|
||||
|
||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -576,9 +576,8 @@ where
|
|||
|
||||
if desired_settings.contains(DesiredSensorSettings::RUN_GAS_SEL) {
|
||||
debug!("RUN_GAS_SEL: true");
|
||||
let gas_sett_run_gas =
|
||||
boundary_check::<I2C>(gas_sett.run_gas, "GasSett.run_gas", 0, 1)?;
|
||||
data = (data as (i32) & !0x10i32 | gas_sett_run_gas as (i32) << 4i32 & 0x10i32)
|
||||
data = (data as (i32) & !0x10i32
|
||||
| gas_sett.run_gas_measurement as (i32) << 4i32 & 0x10i32)
|
||||
as (u8);
|
||||
}
|
||||
|
||||
|
@ -642,8 +641,8 @@ where
|
|||
.contains(DesiredSensorSettings::RUN_GAS_SEL | DesiredSensorSettings::NBCONV_SEL)
|
||||
{
|
||||
sensor_settings.gas_sett.nb_conv = (data_array[1usize] as (i32) & 0xfi32) as (u8);
|
||||
sensor_settings.gas_sett.run_gas =
|
||||
Some(((data_array[1usize] as (i32) & 0x10i32) >> 4i32) as (u8));
|
||||
sensor_settings.gas_sett.run_gas_measurement =
|
||||
((data_array[1usize] as (i32) & 0x10i32) >> 4i32) == 0;
|
||||
}
|
||||
|
||||
Ok(sensor_settings)
|
||||
|
@ -758,7 +757,7 @@ where
|
|||
tph_dur = tph_dur.wrapping_div(1000u32);
|
||||
tph_dur = tph_dur.wrapping_add(1u32);
|
||||
let mut duration = Duration::from_millis(tph_dur as u64);
|
||||
if sensor_settings.gas_sett.run_gas.unwrap_or(0) != 0 {
|
||||
if sensor_settings.gas_sett.run_gas_measurement {
|
||||
duration = duration + sensor_settings.gas_sett.heatr_dur.expect("Heatrdur");
|
||||
}
|
||||
Ok(duration)
|
||||
|
|
|
@ -45,9 +45,13 @@ impl Clone for TphSett {
|
|||
#[repr(C)]
|
||||
pub struct GasSett {
|
||||
pub nb_conv: u8,
|
||||
/// Heater control
|
||||
pub heatr_ctrl: Option<u8>,
|
||||
pub run_gas: Option<u8>,
|
||||
/// Enable measurement of gas, disabled by default
|
||||
pub run_gas_measurement: bool,
|
||||
/// Heater temperature
|
||||
pub heatr_temp: Option<u16>,
|
||||
/// Profile duration
|
||||
pub heatr_dur: Option<Duration>,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue