Struct adafruit_nxp::Magnetometer
source · [−]pub struct Magnetometer {
pub raw_data: Data,
pub data: ScaledData,
pub scaled_data: ScaledData,
/* private fields */
}
Expand description
Magnetometer sensor
This sensor is used to measure the magnetic field around the device. The sensor is connected to the I2C bus and is configured with defaults values. Within this structure you have access to raw data and converted data.
Fields
raw_data: Data
Raw data from the magnetometer sensor.
data: ScaledData
Data from the magnetometer sensor converted to uT but without corrections.
scaled_data: ScaledData
Scaled data from the magnetometer sensor in µT with corrections.
Implementations
sourceimpl Magnetometer
impl Magnetometer
sourcepub fn new(sensor_id: i32) -> Self
pub fn new(sensor_id: i32) -> Self
Creates a new magnetometer sensor.
Arguments
sensor_id
- The sensor id to name the device (usually0x8700B
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 set_hard_soft_iron(
&mut self,
hard_iron: Vector3<f32>,
soft_iron: Matrix3<f32>
)
pub fn set_hard_soft_iron(
&mut self,
hard_iron: Vector3<f32>,
soft_iron: Matrix3<f32>
)
Set hard iron offset to the magnetometer sensor on all axis.
This function is used for calibration purposes. Data must be in µT. Offset only affects the scaled data. If you don’t want to set the soft iron, put an identity matrix.
sourcepub fn get_raw_x(&self) -> i16
pub fn get_raw_x(&self) -> i16
Get Raw data from the magnetometer 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 magnetometer 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 magnetometer 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 magnetometer sensor on the all axis.
Returns a Data
structure with signed 16-bit integers.
sourcepub fn get_x(&self) -> f32
pub fn get_x(&self) -> f32
Get data from the magnetometer sensor on the X-axis without correction.
Returns the magnetic field in µT.
sourcepub fn get_y(&self) -> f32
pub fn get_y(&self) -> f32
Get data from the magnetometer sensor on the Y-axis without correction.
Returns the magnetic field in µT.
sourcepub fn get_z(&self) -> f32
pub fn get_z(&self) -> f32
Get data from the magnetometer sensor on the Z-axis without correction.
Returns the magnetic field in µT.
sourcepub fn get_scaled_x(&self) -> f32
pub fn get_scaled_x(&self) -> f32
Get Scaled data from the magnetometer sensor on the X-axis with correction.
Returns the magnetic field in µT as a f32.
sourcepub fn get_scaled_y(&self) -> f32
pub fn get_scaled_y(&self) -> f32
Get Scaled data from the magnetometer sensor on the Y-axis with correction.
Returns the magnetic field in µT as a f32.
sourcepub fn get_scaled_z(&self) -> f32
pub fn get_scaled_z(&self) -> f32
Get Scaled data from the magnetometer sensor on the Z-axis with correction.
Returns the magnetic field in µT as a f32.
sourcepub fn get_scaled_data(&self) -> ScaledData
pub fn get_scaled_data(&self) -> ScaledData
Get Scaled data from the magnetometer sensor on the all axis with correction.
Returns a ScaledData
structure with the magnetic field in µT as a f32.
Auto Trait Implementations
impl RefUnwindSafe for Magnetometer
impl Send for Magnetometer
impl Sync for Magnetometer
impl Unpin for Magnetometer
impl UnwindSafe for Magnetometer
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.