fs3000_rs

Struct FS3000

Source
pub struct FS3000<Device: DeviceType, Client: ClientType, I2C> { /* private fields */ }
Expand description

A client for a FS3000 device via I2C.

When creating this client, the consumer has two make decisions: - Is the connected device a FS3000-1005 or FS3000-1015? The latter can measure larger air velocitys. - Is the consuming code blocking or async?

Both of these decisions are documented using marker traits.

§Blocking Example

use fs3000_rs::prelude::*;

// The [`BlockingBus`] is a fake `embedded_hal::i2c::I2c` for this example.
// In practice, you would create this [`embedded_hal::i2c::I2c`] via your platform hal.
let blocking_bus = BlockingBus::default();

// Assumes the FS3000-1015 (wider measurement range), substitute FS3000_
let mut client = FS3000::<FS3000_1015, Blocking, _>::new(DeviceAddr::default(), blocking_bus);

let mps = client.read_meters_per_second()?;
println!("We're going {mps} meters/second!");

§Async Example

use fs3000_rs::prelude::*;

// The [`BlockingBus`] is a fake `embedded_hal::i2c::I2c` for this example.
// In practice, you would create this [`embedded_hal::i2c::I2c`] via your platform hal.
let async_bus = AsyncBus::default();

let mut client = FS3000::<FS3000_1015, Async, _>::new(DeviceAddr::default(), async_bus);

let mps = client.read_meters_per_second().await.unwrap();
println!("We're going {mps} meters/second!");

Implementations§

Source§

impl<Device: DeviceType, I2C> FS3000<Device, Blocking, I2C>
where I2C: I2c,

Source

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

Create a new FS3000 instance.

Source

pub fn read_meters_per_second(&mut self) -> Result<f32, Error<I2C::Error>>

Fetch a single, meters-per-second airflow measurement from the device.

Source

pub fn read_raw(&mut self) -> Result<u16, Error<I2C::Error>>

Fetch a single, raw measurement from the device.

The measurement must be translated to a real unit for usage, consult the datasheet for details. Otherwise, use FS3000::read_meters_per_second to have this conversion be handled for you.

Source§

impl<Device: DeviceType, I2C> FS3000<Device, Async, I2C>
where I2C: I2c,

Source

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

Create a new FS3000 instance.

Source

pub async fn read_meters_per_second(&mut self) -> Result<f32, Error<I2C::Error>>

Fetch a single, meters-per-second airflow measurement from the device.

Source

pub async fn read_raw(&mut self) -> Result<u16, Error<I2C::Error>>

Fetch a single, raw measurement from the device.

The measurement must be translated to a real unit for usage, consult the datasheet for details. Otherwise, use FS3000::read_meters_per_second to have this conversion be handled for you.

Auto Trait Implementations§

§

impl<Device, Client, I2C> Freeze for FS3000<Device, Client, I2C>
where I2C: Freeze,

§

impl<Device, Client, I2C> RefUnwindSafe for FS3000<Device, Client, I2C>
where I2C: RefUnwindSafe, Client: RefUnwindSafe, Device: RefUnwindSafe,

§

impl<Device, Client, I2C> Send for FS3000<Device, Client, I2C>
where I2C: Send, Client: Send, Device: Send,

§

impl<Device, Client, I2C> Sync for FS3000<Device, Client, I2C>
where I2C: Sync, Client: Sync, Device: Sync,

§

impl<Device, Client, I2C> Unpin for FS3000<Device, Client, I2C>
where I2C: Unpin, Client: Unpin, Device: Unpin,

§

impl<Device, Client, I2C> UnwindSafe for FS3000<Device, Client, I2C>
where I2C: UnwindSafe, Client: UnwindSafe, Device: 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>,

Source§

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>,

Source§

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.