ContinuousSensorAsync

Trait ContinuousSensorAsync 

Source
pub trait ContinuousSensorAsync {
    type Error: Debug;
    type Measurement: Measurement;

    // Required methods
    async fn start_measuring(&mut self) -> Result<(), Self::Error>;
    async fn stop_measuring(&mut self) -> Result<(), Self::Error>;
    async fn measurement_interval_us(&mut self) -> Result<u32, Self::Error>;
    async fn current_measurement(
        &mut self,
    ) -> Result<Option<Self::Measurement>, Self::Error>;
    async fn is_measurement_ready(&mut self) -> Result<bool, Self::Error>;
    async fn next_measurement(
        &mut self,
    ) -> Result<Self::Measurement, Self::Error>;
}
Expand description

A sensor supporting continuous measurement mode.

If the hardware device itself doesn’t support continuous measurements but they can be meaningfully emulated by using a one-shot mode without drawbacks, it may also implement this trait.

Required Associated Types§

Source

type Error: Debug

The error type which may occur on associated functions

Source

type Measurement: Measurement

A type holding the measurements obtained by this sensor

Required Methods§

Source

async fn start_measuring(&mut self) -> Result<(), Self::Error>

Starts continuous measurement.

If the device supports several measurement modes, this function attempts to switch to continuous mode on best effort.

Source

async fn stop_measuring(&mut self) -> Result<(), Self::Error>

Stops continuous measurement.

The mode in which the device is left afterwards is not specified further, but if possible, a sleep mode or equivalent mode should be preferred.

Source

async fn measurement_interval_us(&mut self) -> Result<u32, Self::Error>

Expected amount of time between measurements in microseconds. This may need to communicate with the device to determine the interval based on device settings.

Source

async fn current_measurement( &mut self, ) -> Result<Option<Self::Measurement>, Self::Error>

Returns the most recent measurement. If the sensor cannot provide the measurement current/last measurement at any time (e.g. the register is cleared after it is read), this should return None when there is no new data available.

Source

async fn is_measurement_ready(&mut self) -> Result<bool, Self::Error>

Check if new measurements are available. If the device does not support checking for availability of new measurements (e.g. via some form of data ready indicator), this method should always return true.

Source

async fn next_measurement(&mut self) -> Result<Self::Measurement, Self::Error>

Wait indefinitely until new measurements are available and return them. If the device does not support checking for new measurements (e.g. via some form of data ready indicator), this method should wait for Self::measurement_interval_us and read the measurement opportunistically.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<D: DelayNs, I: CommandInterfaceAsync> ContinuousSensorAsync for SCD40Async<D, I>

Source§

impl<D: DelayNs, I: CommandInterfaceAsync> ContinuousSensorAsync for SCD41Async<D, I>

Source§

impl<D: DelayNs, I: CommandInterfaceAsync> ContinuousSensorAsync for SCD43Async<D, I>

Source§

impl<D: DelayNs, I: CommandInterfaceAsync> ContinuousSensorAsync for SEN60Async<D, I>

Source§

impl<D: DelayNs, I: CommandInterfaceAsync> ContinuousSensorAsync for SEN63CAsync<D, I>

Source§

impl<D: DelayNs, I: CommandInterfaceAsync> ContinuousSensorAsync for SEN65Async<D, I>

Source§

impl<D: DelayNs, I: CommandInterfaceAsync> ContinuousSensorAsync for SEN66Async<D, I>

Source§

impl<D: DelayNs, I: CommandInterfaceAsync> ContinuousSensorAsync for SEN68Async<D, I>

Source§

impl<D: DelayNs, I: RegisterInterfaceAsync> ContinuousSensorAsync for MAX31865Async<D, I>

Source§

impl<D: DelayNs, I: RegisterInterfaceAsync> ContinuousSensorAsync for BL0942Async<D, I>

Source§

impl<D: DelayNs, I: RegisterInterfaceAsync> ContinuousSensorAsync for BME280CommonAsync<D, I, false>

Source§

impl<D: DelayNs, I: RegisterInterfaceAsync> ContinuousSensorAsync for BME280CommonAsync<D, I, true>

Source§

impl<D: DelayNs, I: RegisterInterfaceAsync> ContinuousSensorAsync for BMP390Async<D, I>

Source§

impl<D: DelayNs, I: RegisterInterfaceAsync> ContinuousSensorAsync for MCP9808Async<D, I>

Source§

impl<D: DelayNs, I: RegisterInterfaceAsync> ContinuousSensorAsync for INA219Async<D, I>

Source§

impl<D: DelayNs, I: RegisterInterfaceAsync> ContinuousSensorAsync for INA226Async<D, I>

Source§

impl<D: DelayNs, I: RegisterInterfaceAsync> ContinuousSensorAsync for INA228Async<D, I>

Source§

impl<D: DelayNs, I: RegisterInterfaceAsync> ContinuousSensorAsync for TMP102Async<D, I>

Source§

impl<D: DelayNs, I: RegisterInterfaceAsync> ContinuousSensorAsync for TMP117Async<D, I>