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>,
impl<I2C, E> Tmp1x2<I2C, Continuous>where
I2C: I2c<Error = E>,
sourcepub fn into_one_shot(
self
) -> Result<Tmp1x2<I2C, OneShot>, ModeChangeError<E, Self>>
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>,
impl<I2C, E> Tmp1x2<I2C, OneShot>where
I2C: I2c<Error = E>,
sourcepub fn into_continuous(
self
) -> Result<Tmp1x2<I2C, Continuous>, ModeChangeError<E, Self>>
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>,
impl<I2C, E, MODE> Tmp1x2<I2C, MODE>where
I2C: I2c<Error = E>,
sourcepub fn enable_extended_mode(&mut self) -> Result<(), Error<E>>
pub fn enable_extended_mode(&mut self) -> Result<(), Error<E>>
Enable the extended measurement mode.
This allows measurement of temperatures above 128°C.
sourcepub fn disable_extended_mode(&mut self) -> Result<(), Error<E>>
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.
sourcepub fn set_conversion_rate(&mut self, rate: CR) -> Result<(), Error<E>>
pub fn set_conversion_rate(&mut self, rate: CR) -> Result<(), Error<E>>
Set the conversion rate when in continuous conversion mode.
sourcepub fn set_high_temperature_threshold(
&mut self,
temperature: f32
) -> Result<(), Error<E>>
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.
sourcepub fn set_low_temperature_threshold(
&mut self,
temperature: f32
) -> Result<(), Error<E>>
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.
sourcepub fn set_fault_queue(&mut self, fq: FaultQueue) -> Result<(), Error<E>>
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.
sourcepub fn set_alert_polarity(
&mut self,
polarity: AlertPolarity
) -> Result<(), Error<E>>
pub fn set_alert_polarity( &mut self, polarity: AlertPolarity ) -> Result<(), Error<E>>
Set the alert polarity.
sourcepub fn set_thermostat_mode(
&mut self,
mode: ThermostatMode
) -> Result<(), Error<E>>
pub fn set_thermostat_mode( &mut self, mode: ThermostatMode ) -> Result<(), Error<E>>
Set the thermostat mode.
sourcepub fn reset_internal_driver_state(&mut self)
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>,
impl<I2C, E> Tmp1x2<I2C, Continuous>where
I2C: I2c<Error = E>,
sourcepub fn read_temperature(&mut self) -> Result<f32, Error<E>>
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>,
impl<I2C, E> Tmp1x2<I2C, OneShot>where
I2C: I2c<Error = E>,
sourcepub fn read_temperature(&mut self) -> Result<f32, Error<E>>
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>,
impl<I2C, E, MODE> Tmp1x2<I2C, MODE>where
I2C: I2c<Error = E>,
sourcepub fn is_comparator_mode_alert_active(&mut self) -> Result<bool, Error<E>>
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.