Skip to main content

Configuration

Struct Configuration 

Source
pub struct Configuration {
    pub high_alert: bool,
    pub low_alert: bool,
    pub data_ready: bool,
    pub eeprom_busy: bool,
    pub mode: ConversionMode,
    pub cycle: ConversionCycle,
    pub averaging: Averaging,
    pub alert_mode: AlertMode,
    pub alert_polarity: AlertPolarity,
    pub alert_pin: AlertPin,
    pub soft_reset: bool,
}
Expand description

A decoded TMP117 configuration register.

Build one, set the fields, and turn it into the 16-bit register value with bits; or parse a register read with from_bits. Configuration::default is the factory state, 0x0220. The four flags are read-only on the device and are ignored when written; soft_reset triggers a 2 ms reset when written and always reads back clear.

§Examples

use pamoja_sensors::tmp117::{Averaging, Configuration, ConversionCycle};

// Average 32 conversions every 4 s, leaving everything else at the factory default.
let config = Configuration {
    cycle: ConversionCycle::S4,
    averaging: Averaging::X32,
    ..Configuration::default()
};
// The high byte then the low byte are written to the configuration register.
let [hi, lo] = config.bits().to_be_bytes();
assert_eq!(Configuration::from_bits(u16::from_be_bytes([hi, lo])), config);
assert_eq!(config.cycle.cycle_micros(config.averaging), 4_000_000);

Fields§

§high_alert: bool

HIGH_Alert flag (bit 15), read-only.

§low_alert: bool

LOW_Alert flag (bit 14), read-only.

§data_ready: bool

Data_Ready flag (bit 13), read-only.

§eeprom_busy: bool

EEPROM_Busy flag (bit 12), read-only.

§mode: ConversionMode

The conversion mode.

§cycle: ConversionCycle

The continuous-mode conversion cycle.

§averaging: Averaging

The number of conversions averaged per result.

§alert_mode: AlertMode

Whether the limits act as alerts or as a therm hysteresis band.

§alert_polarity: AlertPolarity

The ALERT pin’s active level.

§alert_pin: AlertPin

What the ALERT pin reflects.

§soft_reset: bool

Soft_Reset (bit 1): set to trigger a software reset when written.

Implementations§

Source§

impl Configuration

Source

pub fn bits(self) -> u16

Assembles the 16-bit configuration register value.

§Returns

The register value to write, most significant byte first on the bus.

Source

pub fn from_bits(bits: u16) -> Configuration

Parses a 16-bit configuration register value.

§Arguments
  • bits - the register value, as read from the device.
§Returns

The decoded configuration.

Trait Implementations§

Source§

impl Clone for Configuration

Source§

fn clone(&self) -> Configuration

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Configuration

Source§

impl Debug for Configuration

Source§

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

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

impl Default for Configuration

Source§

fn default() -> Self

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

impl Eq for Configuration

Source§

impl PartialEq for Configuration

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for Configuration

Auto Trait Implementations§

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.