[][src]Struct am2320::Am2320

pub struct Am2320<I2C, Delay> { /* fields omitted */ }

Sensor configuration

Methods

impl<I2C, Delay, E> Am2320<I2C, Delay> where
    I2C: Read<Error = E> + Write<Error = E>,
    Delay: DelayUs<u16>, 
[src]

pub fn new(device: I2C, delay: Delay) -> Self[src]

Create a AM2320 temperature sensor driver.

Example with rppal:

This example is not tested
use am2320::*;
use rppal::{hal::Delay, i2c::I2c};
fn main() -> Result<(), Error> {
    let device = I2c::new().expect("could not initialize I2c on your RPi");
    let delay = Delay::new();

    let mut am2320 = Am2320::new(device, delay);

    println!("{:?}", am2320.read());
    Ok(())
}

pub fn read(&mut self) -> Result<Measurement, Error>[src]

Reads one Measurement from the sensor

The operation is blocking, and should take ~3 ms according the spec. This is because the sensor goes into sleep and has to be waken up first. Then it'll wait a while before sending data in-order for the measurement to be more accurate.

Auto Trait Implementations

impl<I2C, Delay> Unpin for Am2320<I2C, Delay> where
    Delay: Unpin,
    I2C: Unpin

impl<I2C, Delay> Send for Am2320<I2C, Delay> where
    Delay: Send,
    I2C: Send

impl<I2C, Delay> Sync for Am2320<I2C, Delay> where
    Delay: Sync,
    I2C: Sync

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]