pub struct AdiAccelerometer { /* private fields */ }devices only.Expand description
A single axis connection to the 3-axis analog accelerometer.
Implementations§
Source§impl AdiAccelerometer
impl AdiAccelerometer
Sourcepub fn new(port: AdiPort, sensitivity: Sensitivity) -> AdiAccelerometer
pub fn new(port: AdiPort, sensitivity: Sensitivity) -> AdiAccelerometer
Create a new accelerometer from an AdiPort.
Sourcepub const fn sensitivity(&self) -> Sensitivity
pub const fn sensitivity(&self) -> Sensitivity
Returns the configured sensitivity of the ADI accelerometer device.
Sourcepub const fn max_acceleration(&self) -> f64
pub const fn max_acceleration(&self) -> f64
Returns the maximum acceleration measurement supported by the current Sensitivity
jumper.
Sourcepub fn acceleration(&self) -> Result<f64, PortError>
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.
- A
PortError::Disconnectederror is returned if no expander was connected to the port. - A
PortError::IncorrectDeviceerror is returned if a device other than an expander was connected to the port.
Sourcepub fn raw_acceleration(&self) -> Result<u16, PortError>
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.
- A
PortError::Disconnectederror is returned if no expander was connected to the port. - A
PortError::IncorrectDeviceerror is returned if a device other than an expander was connected to the port.
Trait Implementations§
Source§impl AdiDevice<1> for AdiAccelerometer
impl AdiDevice<1> for AdiAccelerometer
Source§fn port_numbers(&self) -> [u8; 1]
fn port_numbers(&self) -> [u8; 1]
Source§fn expander_port_number(&self) -> Option<u8>
fn expander_port_number(&self) -> Option<u8>
Source§fn device_type(&self) -> AdiDeviceType
fn device_type(&self) -> AdiDeviceType
AdiDeviceType that this device is associated with.