i2cdev-l3gd20

Crates.ioi2cdev-l3gd20
lib.rsi2cdev-l3gd20
version0.1.3
sourcesrc
created_at2017-08-06 15:53:56.453301
updated_at2017-10-18 22:29:21.169797
descriptionI2C driver for the L3GD20 gyroscope.
homepage
repositoryhttps://github.com/martindeegan/i2cdev-sensors
max_upload_size
id26681
size11,854
Martin Deegan (martindeegan)

documentation

README

L3GD20

An I2C driver for the L3GD20 gyroscope.

Usage

Add the following to your Cargo.toml:

[dependencies]
i2csensors = "0.1.*"
i2cdev-l3gd20 = "0.1.*"

Next, add this to your crate root:

extern crate i2cdev_l3gd20;
extern crate i2csensors;

Initializing and reading from an L3GD20

use i2cdev_l3gd20::*;
use i2csensors::{Gyroscope,Vec3};

fn main() {
    let settings = L3GD20GyroscopeSettings {
        DR: L3GD20GyroscopeDataRate::Hz190,
        BW: L3GD20GyroscopeBandwidth::BW1,
        power_mode: L3GD20PowerMode::Normal,
        zen: true,
        yen: true,
        xen: true,
        sensitivity: L3GD20GyroscopeFS::dps500,
        continuous_update: true,
        high_pass_filter_enabled: true,
        high_pass_filter_mode: Some(L3GD20GyroscopeHighPassFilterMode::NormalMode),
        high_pass_filter_configuration: Some(L3GD20HighPassFilterCutOffConfig::HPCF_0)
    };

    let mut i2cdev = get_linux_l3gd20_i2c_device().unwrap();

    let mut l3gd20_gyro = L3GD20::new(i2cdev, settings).unwrap();

    let angular_rate = l3gd20_gyro.angular_rate_reading().unwrap();
}

Settings can be adjusted according to the datasheet.

Commit count: 52

cargo fmt