Struct adafruit_nxp::Accelerometer
source · [−]pub struct Accelerometer {
pub raw_data: Data,
pub scaled_data: ScaledData,
/* private fields */
}
Expand description
Accelerometer sensor
This sensor is used to measure the acceleration of the device. The sensor is connected to the I2C bus and is configured with defaults values. Within this structure you have access to raw and converted data.
Fields
raw_data: Data
Raw data from the accelerometer.
scaled_data: ScaledData
Scaled data from the accelerometer in m/s².
Implementations
sourceimpl Accelerometer
impl Accelerometer
sourcepub fn new(sensor_id: i32) -> Self
pub fn new(sensor_id: i32) -> Self
Creates a new accelerometer sensor.
Arguments
sensor_id
- The sensor id to name the device (usually0x8700A
as reference to the sensor’s model).
sourcepub fn get_sensor(&self) -> Sensor<'_>
pub fn get_sensor(&self) -> Sensor<'_>
Returns basics information about the sensor.
This field is not yet updated through the initialization.
sourcepub fn get_raw_x(&self) -> i16
pub fn get_raw_x(&self) -> i16
Get Raw data from the accelerometer sensor on the X-axis.
Returns a signed 16-bit integer.
sourcepub fn get_raw_y(&self) -> i16
pub fn get_raw_y(&self) -> i16
Get Raw data from the accelerometer sensor on the Y-axis.
Returns a signed 16-bit integer.
sourcepub fn get_raw_z(&self) -> i16
pub fn get_raw_z(&self) -> i16
Get Raw data from the accelerometer sensor on the Z-axis.
Returns a signed 16-bit integer.
sourcepub fn get_raw_data(&self) -> Data
pub fn get_raw_data(&self) -> Data
Get Raw data from the accelerometer sensor on the all axis.
Returns a Data
structure with signed 16-bit integers.
sourcepub fn get_scaled_x(&self) -> f32
pub fn get_scaled_x(&self) -> f32
Get Scaled data from the accelerometer sensor on the X-axis.
Returns the acceleration in m/s² as a f32.
sourcepub fn get_scaled_y(&self) -> f32
pub fn get_scaled_y(&self) -> f32
Get Scaled data from the accelerometer sensor on the Y-axis.
Returns the acceleration in m/s² as a f32.
sourcepub fn get_scaled_z(&self) -> f32
pub fn get_scaled_z(&self) -> f32
Get Scaled data from the accelerometer sensor on the Z-axis.
Returns the acceleration in m/s² as a f32.
sourcepub fn get_scaled_data(&self) -> ScaledData
pub fn get_scaled_data(&self) -> ScaledData
Get Scaled data from the accelerometer sensor on the all axis.
Returns a ScaledData
structure with the acceleration in m/s² as a f32.
sourcepub fn set_offset(&mut self, x: f32, y: f32, z: f32)
pub fn set_offset(&mut self, x: f32, y: f32, z: f32)
Set offset data to the accelerometer sensor on all axis.
This function is used for calibration purposes. Data must be in m/s². Offset only affects the scaled data.
To find the offset values, refer to the file accel_gyro_calibration.rs
in the examples DIR.
Or you use the calibration function in the main lib to auto set the offsets.
By using this function you won’t need to manually use set_offset()
.
Auto Trait Implementations
impl RefUnwindSafe for Accelerometer
impl Send for Accelerometer
impl Sync for Accelerometer
impl Unpin for Accelerometer
impl UnwindSafe for Accelerometer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.