AdiAccelerometer

Struct AdiAccelerometer 

Source
pub struct AdiAccelerometer { /* private fields */ }
Available on crate feature devices only.
Expand description

A single axis connection to the 3-axis analog accelerometer.

Implementations§

Source§

impl AdiAccelerometer

Source

pub fn new(port: AdiPort, sensitivity: Sensitivity) -> AdiAccelerometer

Create a new accelerometer from an AdiPort.

Source

pub const fn sensitivity(&self) -> Sensitivity

Returns the configured sensitivity of the ADI accelerometer device.

Source

pub const fn max_acceleration(&self) -> f64

Returns the maximum acceleration measurement supported by the current Sensitivity jumper.

Source

pub fn acceleration(&self) -> Result<f64, PortError>

Returns the current acceleration measurement for this axis in g (~9.8 m/s/s).

§Errors

These errors are only returned if the device is plugged into an AdiExpander.

Source

pub fn raw_acceleration(&self) -> Result<u16, PortError>

Returns the raw acceleration reading from [0, 4096]. This represents an ADC-converted analog input from 0-5V.

For example, when on high sensitivity a value of 4096 would represent a reading of 6g (Sensitivity::HIGH_MAX_ACCELERATION). When on low acceleration, this same value would instead represent a 2g reading (Sensitivity::LOW_MAX_ACCELERATION).

§Errors

These errors are only returned if the device is plugged into an AdiExpander.

Trait Implementations§

Source§

impl AdiDevice<1> for AdiAccelerometer

Source§

fn port_numbers(&self) -> [u8; 1]

Returns the port numbers of the AdiPorts that this device is registered to. Read more
Source§

fn expander_port_number(&self) -> Option<u8>

Returns the port number of the SmartPort this device’s expander is connected to, or [None] if the device is plugged into an onboard ADI port. Read more
Source§

fn device_type(&self) -> AdiDeviceType

Returns the variant of AdiDeviceType that this device is associated with.
Source§

const UPDATE_INTERVAL: Duration = ADI_UPDATE_INTERVAL

Update rate of ADI devices.
Source§

impl Debug for AdiAccelerometer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AdiAccelerometer

Source§

fn eq(&self, other: &AdiAccelerometer) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for AdiAccelerometer

Source§

impl StructuralPartialEq for AdiAccelerometer

Auto Trait Implementations§

§

impl Freeze for AdiAccelerometer

§

impl RefUnwindSafe for AdiAccelerometer

§

impl Send for AdiAccelerometer

§

impl Sync for AdiAccelerometer

§

impl Unpin for AdiAccelerometer

§

impl UnwindSafe for AdiAccelerometer

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.