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.os_temp = Some(OversamplingSetting::OS8x);
|
||||||
sensor_settings.tph_sett.filter = Some(2);
|
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_dur = Some(Duration::from_millis(1500));
|
||||||
sensor_settings.gas_sett.heatr_temp = Some(320);
|
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) {
|
if desired_settings.contains(DesiredSensorSettings::RUN_GAS_SEL) {
|
||||||
debug!("RUN_GAS_SEL: true");
|
debug!("RUN_GAS_SEL: true");
|
||||||
let gas_sett_run_gas =
|
data = (data as (i32) & !0x10i32
|
||||||
boundary_check::<I2C>(gas_sett.run_gas, "GasSett.run_gas", 0, 1)?;
|
| gas_sett.run_gas_measurement as (i32) << 4i32 & 0x10i32)
|
||||||
data = (data as (i32) & !0x10i32 | gas_sett_run_gas as (i32) << 4i32 & 0x10i32)
|
|
||||||
as (u8);
|
as (u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,8 +641,8 @@ where
|
||||||
.contains(DesiredSensorSettings::RUN_GAS_SEL | DesiredSensorSettings::NBCONV_SEL)
|
.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.nb_conv = (data_array[1usize] as (i32) & 0xfi32) as (u8);
|
||||||
sensor_settings.gas_sett.run_gas =
|
sensor_settings.gas_sett.run_gas_measurement =
|
||||||
Some(((data_array[1usize] as (i32) & 0x10i32) >> 4i32) as (u8));
|
((data_array[1usize] as (i32) & 0x10i32) >> 4i32) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(sensor_settings)
|
Ok(sensor_settings)
|
||||||
|
@ -758,7 +757,7 @@ where
|
||||||
tph_dur = tph_dur.wrapping_div(1000u32);
|
tph_dur = tph_dur.wrapping_div(1000u32);
|
||||||
tph_dur = tph_dur.wrapping_add(1u32);
|
tph_dur = tph_dur.wrapping_add(1u32);
|
||||||
let mut duration = Duration::from_millis(tph_dur as u64);
|
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");
|
duration = duration + sensor_settings.gas_sett.heatr_dur.expect("Heatrdur");
|
||||||
}
|
}
|
||||||
Ok(duration)
|
Ok(duration)
|
||||||
|
|
|
@ -45,9 +45,13 @@ impl Clone for TphSett {
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct GasSett {
|
pub struct GasSett {
|
||||||
pub nb_conv: u8,
|
pub nb_conv: u8,
|
||||||
|
/// Heater control
|
||||||
pub heatr_ctrl: Option<u8>,
|
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>,
|
pub heatr_temp: Option<u16>,
|
||||||
|
/// Profile duration
|
||||||
pub heatr_dur: Option<Duration>,
|
pub heatr_dur: Option<Duration>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue