pub struct Movement<I2C> { /* private fields */ }Expand description
Driver for the Modulino Movement module (LSM6DSOX IMU).
§Example
ⓘ
use modulino::Movement;
let mut movement = Movement::new(i2c)?;
// Read acceleration
let accel = movement.acceleration()?;
println!("Accel: x={:.2}g, y={:.2}g, z={:.2}g", accel.x, accel.y, accel.z);
// Read angular velocity
let gyro = movement.angular_velocity()?;
println!("Gyro: x={:.2}dps, y={:.2}dps, z={:.2}dps", gyro.x, gyro.y, gyro.z);Implementations§
Source§impl<I2C, E> Movement<I2C>where
I2C: I2c<Error = E>,
impl<I2C, E> Movement<I2C>where
I2C: I2c<Error = E>,
Sourcepub fn new(i2c: I2C) -> Result<Self, E>
pub fn new(i2c: I2C) -> Result<Self, E>
Create a new Movement instance with the default address (0x6A).
Sourcepub fn new_with_address(i2c: I2C, address: u8) -> Result<Self, E>
pub fn new_with_address(i2c: I2C, address: u8) -> Result<Self, E>
Create a new Movement instance with a custom address.
Valid addresses are 0x6A or 0x6B depending on the SA0 pin configuration.
Sourcepub fn acceleration(&mut self) -> Result<MovementValues, E>
pub fn acceleration(&mut self) -> Result<MovementValues, E>
Read acceleration values.
Returns acceleration in g (gravitational units).
Sourcepub fn acceleration_magnitude(&mut self) -> Result<f32, E>
pub fn acceleration_magnitude(&mut self) -> Result<f32, E>
Get the magnitude of acceleration.
When at rest on Earth, this should be approximately 1.0g due to gravity.
Sourcepub fn angular_velocity(&mut self) -> Result<MovementValues, E>
pub fn angular_velocity(&mut self) -> Result<MovementValues, E>
Read angular velocity (gyroscope) values.
Returns angular velocity in degrees per second (dps).
Sourcepub fn gyro(&mut self) -> Result<MovementValues, E>
pub fn gyro(&mut self) -> Result<MovementValues, E>
Alias for angular_velocity().
Sourcepub fn data_ready(&mut self) -> Result<bool, E>
pub fn data_ready(&mut self) -> Result<bool, E>
Check if new data is available.
Auto Trait Implementations§
impl<I2C> Freeze for Movement<I2C>where
I2C: Freeze,
impl<I2C> RefUnwindSafe for Movement<I2C>where
I2C: RefUnwindSafe,
impl<I2C> Send for Movement<I2C>where
I2C: Send,
impl<I2C> Sync for Movement<I2C>where
I2C: Sync,
impl<I2C> Unpin for Movement<I2C>where
I2C: Unpin,
impl<I2C> UnwindSafe for Movement<I2C>where
I2C: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more