Struct Config

Source
pub struct Config(/* private fields */);
Expand description

Config register.

This register sets the rate, filter, and interface options of the device. Writes to the config register in normal mode may be ignored. In sleep mode writes are not ignored.

All methods on this struct are constant so that you can create a configuration value at compile time.

§Example

use bme280_multibus::{Config, Filter, Standby};

const CONFIG: Config = Config::RESET
    .set_standby_time(Standby::Millis1000)
    .set_filter(Filter::X16)
    .set_spi3w_en(false);

Implementations§

Source§

impl Config

Source

pub const RESET: Self

Get the reset value of the config register.

§Example
use bme280_multibus::Config;

assert_eq!(Config::RESET, Config::default());
Source

pub const fn set_standby_time(self, s: Standby) -> Config

Set the inactive duration tstandby in normal mode.

See Standby for settings, and chapter 3.3.4 in the datasheet for details.

§Example
use bme280_multibus::{Config, Standby};

let mut cfg: Config = Config::default();
assert_eq!(cfg.standby_time(), Standby::default());
cfg = cfg.set_standby_time(Standby::Micros500);
assert_eq!(cfg.standby_time(), Standby::Micros500);
cfg = cfg.set_standby_time(Standby::Micros62500);
assert_eq!(cfg.standby_time(), Standby::Micros62500);
cfg = cfg.set_standby_time(Standby::Millis125);
assert_eq!(cfg.standby_time(), Standby::Millis125);
cfg = cfg.set_standby_time(Standby::Millis250);
assert_eq!(cfg.standby_time(), Standby::Millis250);
cfg = cfg.set_standby_time(Standby::Millis500);
assert_eq!(cfg.standby_time(), Standby::Millis500);
cfg = cfg.set_standby_time(Standby::Millis1000);
assert_eq!(cfg.standby_time(), Standby::Millis1000);
cfg = cfg.set_standby_time(Standby::Millis10);
assert_eq!(cfg.standby_time(), Standby::Millis10);
cfg = cfg.set_standby_time(Standby::Millis20);
assert_eq!(cfg.standby_time(), Standby::Millis20);
Source

pub const fn standby_time(&self) -> Standby

Get the standby time.

Source

pub const fn set_filter(self, f: Filter) -> Config

Set the time constant of the IIR filter.

See Filter for settings, and chapter 3.4.4 in the datasheet for details.

§Example
use bme280_multibus::{Config, Filter};

let mut cfg: Config = Config::default();
assert_eq!(cfg.filter(), Filter::default());
cfg = cfg.set_filter(Filter::Off);
assert_eq!(cfg.filter(), Filter::Off);
cfg = cfg.set_filter(Filter::X2);
assert_eq!(cfg.filter(), Filter::X2);
cfg = cfg.set_filter(Filter::X4);
assert_eq!(cfg.filter(), Filter::X4);
cfg = cfg.set_filter(Filter::X8);
assert_eq!(cfg.filter(), Filter::X8);
cfg = cfg.set_filter(Filter::X16);
assert_eq!(cfg.filter(), Filter::X16);
Source

pub const fn filter(&self) -> Filter

Get the filter coefficient.

Source

pub const fn set_spi3w_en(self, en: bool) -> Config

Enables the 3-wire SPI itnerface when enabled.

See chapter 6.3 in the datasheet for details.

§Example
use bme280_multibus::Config;

let mut cfg: Config = Config::default();
assert_eq!(cfg.spi3w_en(), false);
cfg = cfg.set_spi3w_en(true);
assert_eq!(cfg.spi3w_en(), true);
cfg = cfg.set_spi3w_en(false);
assert_eq!(cfg.spi3w_en(), false);
Source

pub const fn spi3w_en(&self) -> bool

Returns true if 3-wire SPI is enabled.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Hash for Config

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Config

Source§

impl Eq for Config

Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.