Trait kernel::hil::sensors::ProximityDriver

source ·
pub trait ProximityDriver<'a> {
    // Required methods
    fn set_client(&self, client: &'a dyn ProximityClient);
    fn read_proximity(&self) -> Result<(), ErrorCode>;
    fn read_proximity_on_interrupt(
        &self,
        low_threshold: u8,
        high_threshold: u8
    ) -> Result<(), ErrorCode>;
}
Expand description

A basic interface for a proximity sensor

Required Methods§

source

fn set_client(&self, client: &'a dyn ProximityClient)

source

fn read_proximity(&self) -> Result<(), ErrorCode>

Callback issued after sensor reads proximity value

source

fn read_proximity_on_interrupt( &self, low_threshold: u8, high_threshold: u8 ) -> Result<(), ErrorCode>

Callback issued after sensor reads proximity value greater than ‘high_threshold’ or less than ‘low_threshold’

To elaborate, the callback is not issued by the driver until (prox_reading >= high_threshold || prox_reading <= low_threshold). When (prox_reading >= high_threshold || prox_reading <= low_threshold) is read by the sensor, an I2C interrupt is generated and sent to the kernel which prompts the driver to collect the proximity reading from the sensor and perform the callback. Any apps issuing this command will have to wait for the proximity reading to fall within the aforementioned ranges in order to received a callback. Threshold: A value of range [0 , 255] which represents at what proximity reading ranges an interrupt will occur.

Implementors§