Struct aht20_driver::AHT20Initialized
source · pub struct AHT20Initialized<'a, I>{ /* 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>
impl<'a, E, I> AHT20Initialized<'a, I>
sourcepub fn measure(
&mut self,
delay: &mut (impl DelayUs<u16> + DelayMs<u16>)
) -> Result<SensorReading, Error<E>>
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
sourcepub fn measure_no_fp(
&mut self,
delay: &mut (impl DelayUs<u16> + DelayMs<u16>)
) -> Result<SensorReading, Error<E>>
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.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more