Struct tmp1x2::Tmp1x2

source ·
pub struct Tmp1x2<I2C, MODE> { /* private fields */ }
Expand description

TMP1X2 device driver.

Implementations§

source§

impl<I2C, E> Tmp1x2<I2C, Continuous>
where I2C: I2c<Error = E>,

source

pub fn into_one_shot( self ) -> Result<Tmp1x2<I2C, OneShot>, ModeChangeError<E, Self>>

Change into one-shot conversion mode (shutdown).

If the mode change failed you will get a ModeChangeError. You can get the unchanged device back from it.

source§

impl<I2C, E> Tmp1x2<I2C, OneShot>
where I2C: I2c<Error = E>,

source

pub fn into_continuous( self ) -> Result<Tmp1x2<I2C, Continuous>, ModeChangeError<E, Self>>

Change into continuous conversion mode.

If the mode change failed you will get a ModeChangeError. You can get the unchanged device back from it.

source§

impl<I2C, E, MODE> Tmp1x2<I2C, MODE>
where I2C: I2c<Error = E>,

source

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

Enable the extended measurement mode.

This allows measurement of temperatures above 128°C.

source

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

Disable the extended measurement mode.

This puts the device in normal measurement mode. It will not measure temperatures above 128°C.

source

pub fn set_conversion_rate(&mut self, rate: CR) -> Result<(), Error<E>>

Set the conversion rate when in continuous conversion mode.

source

pub fn set_high_temperature_threshold( &mut self, temperature: f32 ) -> Result<(), Error<E>>

Set the high temperature threshold.

The value provided will be capped to be in the interval [-128.0, 127.9375] in normal mode and [-256.0, 255.875] in extended mode.

source

pub fn set_low_temperature_threshold( &mut self, temperature: f32 ) -> Result<(), Error<E>>

Set the low temperature threshold.

The value provided will be capped to be in the interval [-128.0, 127.9375] in normal mode and [-256.0, 255.875] in extended mode.

source

pub fn set_fault_queue(&mut self, fq: FaultQueue) -> Result<(), Error<E>>

Set the fault queue.

Set the number of consecutive faults that will trigger an alert.

source

pub fn set_alert_polarity( &mut self, polarity: AlertPolarity ) -> Result<(), Error<E>>

Set the alert polarity.

source

pub fn set_thermostat_mode( &mut self, mode: ThermostatMode ) -> Result<(), Error<E>>

Set the thermostat mode.

source

pub fn reset_internal_driver_state(&mut self)

Reset the internal state of this driver to the default values.

Note: This does not alter the state or configuration of the device.

This resets the cached configuration register value in this driver to the power-up (reset) configuration of the device.

This needs to be called after performing a reset on the device, for example through an I2C general-call Reset command, which was not done through this driver to ensure that the configurations in the device and in the driver match.

source§

impl<I2C, E> Tmp1x2<I2C, Continuous>
where I2C: I2c<Error = E>,

source

pub fn read_temperature(&mut self) -> Result<f32, Error<E>>

Read the temperature from the sensor.

source§

impl<I2C, E> Tmp1x2<I2C, OneShot>
where I2C: I2c<Error = E>,

source

pub fn read_temperature(&mut self) -> Result<f32, Error<E>>

Perform a one-shot temperature measurement.

This allows triggering a single temperature measurement when in shutdown mode. The device returns to the shutdown state at the completion of the temperature conversion. This reduces power consumption when continuous temperature monitoring is not required.

If no temperature conversion was started yet, calling this method will start one and return nb::Error::WouldBlock. Subsequent calls will continue to return nb::Error::WouldBlock until the temperature measurement is finished. Then it will return the measured temperature.

source§

impl<I2C, E, MODE> Tmp1x2<I2C, MODE>
where I2C: I2c<Error = E>,

source

pub fn is_comparator_mode_alert_active(&mut self) -> Result<bool, Error<E>>

Read whether an alert is active as defined by the comparator mode.

NOTE: This ignores the thermostat mode setting and always corresponds to the activation status as defined by the comparator mode.

This method takes into account the alert polarity selected.

See also: ThermostatMode, AlertPolarity.

source§

impl<I2C, E> Tmp1x2<I2C, Continuous>
where I2C: I2c<Error = E>,

source

pub fn new(i2c: I2C, address: SlaveAddr) -> Self

Create new instance of the TMP102 or TMP112x device.

By default they are in continuous conversion mode.

source§

impl<I2C, MODE> Tmp1x2<I2C, MODE>

source

pub fn destroy(self) -> I2C

Destroy driver instance, return I²C bus instance.

Trait Implementations§

source§

impl<I2C: Debug, MODE: Debug> Debug for Tmp1x2<I2C, MODE>

source§

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

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

impl<I2C: Default, MODE: Default> Default for Tmp1x2<I2C, MODE>

source§

fn default() -> Tmp1x2<I2C, MODE>

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

Auto Trait Implementations§

§

impl<I2C, MODE> RefUnwindSafe for Tmp1x2<I2C, MODE>
where I2C: RefUnwindSafe, MODE: RefUnwindSafe,

§

impl<I2C, MODE> Send for Tmp1x2<I2C, MODE>
where I2C: Send, MODE: Send,

§

impl<I2C, MODE> Sync for Tmp1x2<I2C, MODE>
where I2C: Sync, MODE: Sync,

§

impl<I2C, MODE> Unpin for Tmp1x2<I2C, MODE>
where I2C: Unpin, MODE: Unpin,

§

impl<I2C, MODE> UnwindSafe for Tmp1x2<I2C, MODE>
where I2C: UnwindSafe, MODE: 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>,

§

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

§

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.