Struct Device

Source
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>

Source

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.

Source

pub fn soft_reset(&mut self) -> Result<(), Error>

Triggers a soft-resets of the sensor.

Source

pub fn set_config(&mut self, conf: DeviceConfig) -> Result<(), Error>

Used to set the oversampling, filter and odr configuration.

Source

pub fn get_conf(&mut self, conf: &mut DeviceConfig) -> Result<(), Error>

Used to get the oversampling, filter and odr configurations.

Source

pub fn set_op_mode(&mut self, op_mode: OperationMode) -> Result<(), Error>

Used to set the operation mode of the sensor.

Source

pub fn get_op_mode(&mut self) -> Result<OperationMode, Error>

Used to get the operation mode of the sensor.

Source

pub fn get_measure_duration(&mut self, op_mode: OperationMode) -> u32

Used to get the remaining duration that can be used for heating.

Source

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.

Source

pub fn set_gas_heater_conf( &mut self, op_mode: OperationMode, conf: GasHeaterConfig, ) -> Result<(), Error>

Used to set the gas configuration of the sensor.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.