pub struct Device<I: Interface> {
pub interface: I,
pub config: DeviceConfig,
pub gas_heater_config: GasHeaterConfig,
/* private fields */
}
Expand description
BME68x Device Controller
let mut bme = Device::initialize(SpiDriver {
spicl: args.spicl,
tty: args.tty,
})?;
bme.set_config(DeviceConfigig::default()
.filter(0)
.odr(8)
.oversample_humidity(5)
.oversample_pressure(1)
.oversample_temperature(2))?;
Fields§
§interface: I
§config: DeviceConfig
§gas_heater_config: GasHeaterConfig
Implementations§
Source§impl<I: Interface> Device<I>
impl<I: Interface> Device<I>
Sourcepub fn initialize(interface: I) -> Result<Self, Error>
pub fn initialize(interface: I) -> Result<Self, Error>
Initialization.
Reads the chip-id of the sensor which is the first step to verify the sensor and also calibrates the sensor.
Sourcepub fn soft_reset(&mut self) -> Result<(), Error>
pub fn soft_reset(&mut self) -> Result<(), Error>
Triggers a soft-resets of the sensor.
Sourcepub fn set_config(&mut self, conf: DeviceConfig) -> Result<(), Error>
pub fn set_config(&mut self, conf: DeviceConfig) -> Result<(), Error>
Used to set the oversampling, filter and odr configuration.
Sourcepub fn get_conf(&mut self, conf: &mut DeviceConfig) -> Result<(), Error>
pub fn get_conf(&mut self, conf: &mut DeviceConfig) -> Result<(), Error>
Used to get the oversampling, filter and odr configurations.
Sourcepub fn set_op_mode(&mut self, op_mode: OperationMode) -> Result<(), Error>
pub fn set_op_mode(&mut self, op_mode: OperationMode) -> Result<(), Error>
Used to set the operation mode of the sensor.
Sourcepub fn get_op_mode(&mut self) -> Result<OperationMode, Error>
pub fn get_op_mode(&mut self) -> Result<OperationMode, Error>
Used to get the operation mode of the sensor.
Sourcepub fn get_measure_duration(&mut self, op_mode: OperationMode) -> u32
pub fn get_measure_duration(&mut self, op_mode: OperationMode) -> u32
Used to get the remaining duration that can be used for heating.
Sourcepub fn get_data(
&mut self,
op_mode: u8,
data: *mut SensorData,
n_data: &mut u8,
) -> Result<(), Error>
pub fn get_data( &mut self, op_mode: u8, data: *mut SensorData, n_data: &mut u8, ) -> Result<(), Error>
Reads the pressure, temperature humidity and gas data from the sensor, compensates the data and store it in the SensorData structure instance passed by the user.
TODO refactor and make safer.
Sourcepub fn set_gas_heater_conf(
&mut self,
op_mode: OperationMode,
conf: GasHeaterConfig,
) -> Result<(), Error>
pub fn set_gas_heater_conf( &mut self, op_mode: OperationMode, conf: GasHeaterConfig, ) -> Result<(), Error>
Used to set the gas configuration of the sensor.
Sourcepub fn get_gas_heater_conf(
&mut self,
config: GasHeaterConfig,
) -> Result<(), Error>
pub fn get_gas_heater_conf( &mut self, config: GasHeaterConfig, ) -> Result<(), Error>
Used to get the gas configuration of the sensor.
Auto Trait Implementations§
impl<I> Freeze for Device<I>where
I: Freeze,
impl<I> RefUnwindSafe for Device<I>where
I: RefUnwindSafe,
impl<I> !Send for Device<I>
impl<I> !Sync for Device<I>
impl<I> Unpin for Device<I>where
I: Unpin,
impl<I> UnwindSafe for Device<I>where
I: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more