Struct person_sensor::PersonSensor

source ·
pub struct PersonSensor<I2C, INT, MODE> { /* private fields */ }
Expand description

The person sensor driver.

The sensor can be used in two modes: continuous capture and standby. In continuous capture mode, the sensor continuously captures frames and sends the results over I2C. In standby mode, the sensor is in a low-power state and only captures a single frame when requested.

To create the sensor, use the PersonSensorBuilder. The builder allows you to set the mode and interrupt pin.

Example:

let sda = p.PIN_2;
let scl = p.PIN_3;
let i2c = I2c::new_async(p.I2C1, scl, sda, Irqs, Config::default());
let interrupt = p.PIN_4;

let mut person_sensor = PersonSensorBuilder::new_continuous(i2c)
    .with_interrupt(interrupt)
    .build()
    .await
    .unwrap();

loop {
   if let Ok(result) = person_sensor.get_detections().await {
       // Do something with the results
   }
}

Implementations§

source§

impl<I2C, INT, MODE> PersonSensor<I2C, INT, MODE>
where I2C: I2c,

source

pub async fn enable_id_model(&mut self, enable: bool) -> Result<(), I2C::Error>

Enable / Disable the ID model. With this flag set to false, only bounding boxes are captured and the framerate is increased.

source

pub async fn label_next_id(&mut self, id: PersonID) -> Result<(), I2C::Error>

Calibrate the next identified frame as person N, from 0 to 7. If two frames pass with no person, this label is discarded.

Note: this will not return the result of the calibration, the only failure is if the I2C write fails.

source

pub async fn set_persist_ids(&mut self, persist: bool) -> Result<(), I2C::Error>

Store any recognized IDs even when unpowered.

source

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

Wipe any recognized IDs from storage.

source

pub async fn set_indicator(&mut self, enabled: bool) -> Result<(), I2C::Error>

Whether to enable the LED indicator on the sensor.

source§

impl<I2C, INT> PersonSensor<I2C, INT, StandbyMode>
where I2C: I2c,

source

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

Capture a single frame and reads the results

source

pub async fn into_continuous_mode( self, ) -> Result<PersonSensor<I2C, INT, ContinuousCaptureMode>, I2C::Error>

Switches the sensor to continuous capture mode

source§

impl<I2C, INT> PersonSensor<I2C, INT, ContinuousCaptureMode>
where I2C: I2c,

source

pub async fn into_standby_mode( self, ) -> Result<PersonSensor<I2C, INT, StandbyMode>, I2C::Error>

Switches the sensor into a lower power standby mode. Only single-shot capture is possible in this mode.

source

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

Returns the latest results from the sensor.

source§

impl<I2C, INT> PersonSensor<I2C, INT, ContinuousCaptureMode>
where INT: Wait,

source

pub async fn wait_for_person(&mut self) -> Result<(), INT::Error>

Wait for the person sensor to trigger an interrupt indicating a person has been detected. Returns immediately if a person is currently detected.

Auto Trait Implementations§

§

impl<I2C, INT, MODE> Freeze for PersonSensor<I2C, INT, MODE>
where I2C: Freeze, INT: Freeze,

§

impl<I2C, INT, MODE> RefUnwindSafe for PersonSensor<I2C, INT, MODE>
where I2C: RefUnwindSafe, INT: RefUnwindSafe, MODE: RefUnwindSafe,

§

impl<I2C, INT, MODE> Send for PersonSensor<I2C, INT, MODE>
where I2C: Send, INT: Send, MODE: Send,

§

impl<I2C, INT, MODE> Sync for PersonSensor<I2C, INT, MODE>
where I2C: Sync, INT: Sync, MODE: Sync,

§

impl<I2C, INT, MODE> Unpin for PersonSensor<I2C, INT, MODE>
where I2C: Unpin, INT: Unpin, MODE: Unpin,

§

impl<I2C, INT, MODE> UnwindSafe for PersonSensor<I2C, INT, MODE>
where I2C: UnwindSafe, INT: UnwindSafe, MODE: 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>,

§

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.