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

Creates a new accelerometer sensor.
Arguments
  • sensor_id - The sensor id to name the device (usually 0x8700A as reference to the sensor’s model).
Returns basics information about the sensor.

This field is not yet updated through the initialization.

Get Raw data from the accelerometer sensor on the all axis.

Returns a Data structure with signed 16-bit integers.

Get Scaled data from the accelerometer sensor on the X-axis.

Returns the acceleration in m/s² as a f32.

Get Scaled data from the accelerometer sensor on the Y-axis.

Returns the acceleration in m/s² as a f32.

Get Scaled data from the accelerometer sensor on the Z-axis.

Returns the acceleration in m/s² as a f32.

Get Scaled data from the accelerometer sensor on the all axis.

Returns a ScaledData structure with the acceleration in m/s² as a 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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.