Struct aht20_driver::AHT20Initialized

source ·
pub struct AHT20Initialized<'a, I>
where I: Read + Write,
{ /* private fields */ }
Expand description

AHT20Initialized is returned by AHT20::init() and the sensor is ready to read from.

In this state you can trigger a measurement with .measure(&mut delay).

Implementations§

source§

impl<'a, E, I> AHT20Initialized<'a, I>
where I: Read<Error = E> + Write<Error = E>,

source

pub fn measure( &mut self, delay: &mut (impl DelayUs<u16> + DelayMs<u16>) ) -> Result<SensorReading, Error<E>>

Measure temperature and humidity.

This masurement takes at least 80ms to complete. Together with the measure_once method, this is the work being carried out:

Command::TriggerMeasurement (0xAC)   ◄─┐
                 │                     │
                 ▼                     │
            Wait 80 ms                 │
                 │                     │
                 ▼                     │
          Read status byte    ◄──┐     │
                 │               │     │
                 ▼               │     │
            Status::Busy  ───►  Yes    │
                 │                     │
                 ▼                     │
                No                     │
                 │                     │
                 ▼                     │
            Read 7 bytes               │
                 │                     │
                 ▼                     │
            Calculate CRC              │
                 │                     │
                 ▼                     │
              CRC good ─► No  ─────────┘
                 │                     ▲
                 ▼                     │
                Yes                    │
                 │                     │
                 ▼                     │
          CRC-checked Ready ─► No ─────┘
                 │
                 ▼
                Yes
                 │
                 ▼
       Calc Humidity and Temp
source

pub fn measure_no_fp( &mut self, delay: &mut (impl DelayUs<u16> + DelayMs<u16>) ) -> Result<SensorReading, Error<E>>

This is identical to measure, except it doesn’t use floating point math.

This means it can be used on microcontrollers with no FP support, without having to bring in floating point math functions, which can take up a lot of space, and might be slow.

The drawback is that precision is limited to only integer values.

source

pub fn soft_reset( &mut self, delay: &mut (impl DelayUs<u16> + DelayMs<u16>) ) -> Result<(), Error<E>>

Send the Soft Reset command to the sensor.

This performs a soft reset, it’s unclear when this might be needed. It takes 20ms to complete and returns nothing.

source

pub fn destroy(self) -> Self

Destroys this initialized driver and lets you release the I2C bus I

Auto Trait Implementations§

§

impl<'a, I> Freeze for AHT20Initialized<'a, I>

§

impl<'a, I> RefUnwindSafe for AHT20Initialized<'a, I>
where I: RefUnwindSafe,

§

impl<'a, I> Send for AHT20Initialized<'a, I>
where I: Send,

§

impl<'a, I> Sync for AHT20Initialized<'a, I>
where I: Sync,

§

impl<'a, I> Unpin for AHT20Initialized<'a, I>

§

impl<'a, I> !UnwindSafe for AHT20Initialized<'a, I>

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.