Struct tmp006::Tmp006

source ·
pub struct Tmp006<I2C> { /* private fields */ }
Expand description

TMP006 device driver.

Implementations§

source§

impl<I2C, E> Tmp006<I2C>
where I2C: I2c<Error = E>,

source

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

Create new instance of the TMP006 device.

source

pub fn destroy(self) -> I2C

Destroy driver instance, return I²C bus instance.

source

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

Enable the sensor (default state).

Sensor and ambient continuous conversion.

Note: calling this clears the data-ready bit.

source

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

Disable the sensor (power-down).

Note: calling this clears the data-ready bit.

source

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

Reset the sensor (software reset).

Note: calling this clears the data-ready bit.

source

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

Enable DRDY pin.

Note: calling this clears the data-ready bit.

source

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

Disable DRDY pin.

Note: calling this clears the data-ready bit.

source

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

Set the ADC conversion rate.

Note: calling this clears the data-ready bit.

source§

impl<I2C, E> Tmp006<I2C>
where I2C: I2c<Error = E>,

source

pub fn read_object_temperature( &mut self, calibration_factor: f64 ) -> Result<f64, Error<E>>

Read the object temperature in Kelvins.

This uses the sensor voltage and ambient temperature as well as an input calibration factor.

The input calibration factor can be calculated with the formulas provided in the [TMP006 user guide]. Typical values are between 5*10^-14 and 7*10^-14

TMP006 user guide

source

pub fn calculate_object_temperature( &self, data: SensorData, calibration_factor: f64 ) -> f64

Calculate the object temperature in Kelvins.

Given the sensor data and a calibration factor.

The input calibration factor can be calculated with the formulas provided in the [TMP006 user guide]. Typical values are between 5*10^-14 and 7*10^-14

TMP006 user guide

source

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

Read the data from the sensor.

These values can be used to calculate the object temperature as done in read_object_temperature().

source

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

Reads whether there is data ready to be read.

When this returens false it means that a conversion is in progress.

source

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

Read the manufacturer ID.

This is per default 0x5449.

source

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

Read the device ID.

This is per default 0x0067.

Trait Implementations§

source§

impl<I2C: Debug> Debug for Tmp006<I2C>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I2C> RefUnwindSafe for Tmp006<I2C>
where I2C: RefUnwindSafe,

§

impl<I2C> Send for Tmp006<I2C>
where I2C: Send,

§

impl<I2C> Sync for Tmp006<I2C>
where I2C: Sync,

§

impl<I2C> Unpin for Tmp006<I2C>
where I2C: Unpin,

§

impl<I2C> UnwindSafe for Tmp006<I2C>
where I2C: 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.