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,
impl<I2C, INT, MODE> PersonSensor<I2C, INT, MODE>where
I2C: I2c,
sourcepub async fn enable_id_model(&mut self, enable: bool) -> Result<(), I2C::Error>
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.
sourcepub async fn label_next_id(&mut self, id: PersonID) -> Result<(), I2C::Error>
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.
sourcepub async fn set_persist_ids(&mut self, persist: bool) -> Result<(), I2C::Error>
pub async fn set_persist_ids(&mut self, persist: bool) -> Result<(), I2C::Error>
Store any recognized IDs even when unpowered.
source§impl<I2C, INT> PersonSensor<I2C, INT, StandbyMode>where
I2C: I2c,
impl<I2C, INT> PersonSensor<I2C, INT, StandbyMode>where
I2C: I2c,
sourcepub async fn capture_once(&mut self) -> Result<PersonSensorResults, I2C::Error>
pub async fn capture_once(&mut self) -> Result<PersonSensorResults, I2C::Error>
Capture a single frame and reads the results
sourcepub async fn into_continuous_mode(
self,
) -> Result<PersonSensor<I2C, INT, ContinuousCaptureMode>, I2C::Error>
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,
impl<I2C, INT> PersonSensor<I2C, INT, ContinuousCaptureMode>where
I2C: I2c,
sourcepub async fn into_standby_mode(
self,
) -> Result<PersonSensor<I2C, INT, StandbyMode>, I2C::Error>
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.
sourcepub async fn get_detections(
&mut self,
) -> Result<PersonSensorResults, I2C::Error>
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,
impl<I2C, INT> PersonSensor<I2C, INT, ContinuousCaptureMode>where
INT: Wait,
sourcepub async fn wait_for_person(&mut self) -> Result<(), INT::Error>
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.