Compare commits
10 commits
11554dee66
...
32604cc16c
Author | SHA1 | Date | |
---|---|---|---|
32604cc16c | |||
![]() |
aeb0e91bc7 | ||
![]() |
d948e4e16c | ||
![]() |
d76cedddbc | ||
![]() |
c29d609545 | ||
![]() |
17c9a709d2 | ||
![]() |
4841c079b6 | ||
![]() |
f54d41e6ed | ||
![]() |
409fcf0cd1 | ||
![]() |
22307711cc |
4 changed files with 24 additions and 95 deletions
|
@ -1,88 +1,24 @@
|
||||||
version: 2
|
version: 2
|
||||||
jobs:
|
jobs:
|
||||||
latest:
|
1dot64:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/rust:latest
|
- image: cimg/rust:1.64.0
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
name: build and test
|
name: build and test
|
||||||
command: cargo build
|
command: cargo build
|
||||||
fournine:
|
1dot63:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/rust:1.49.0
|
- image: cimg/rust:1.63.0
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
name: build and test
|
name: build and test
|
||||||
command: cargo build
|
command: cargo build
|
||||||
foureight:
|
1dot62:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/rust:1.48.0
|
- image: cimg/rust:1.62.0
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run:
|
|
||||||
name: build and test
|
|
||||||
command: cargo build
|
|
||||||
fourseven:
|
|
||||||
docker:
|
|
||||||
- image: circleci/rust:1.47.0
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run:
|
|
||||||
name: build and test
|
|
||||||
command: cargo build
|
|
||||||
foursix:
|
|
||||||
docker:
|
|
||||||
- image: circleci/rust:1.46.0
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run:
|
|
||||||
name: build and test
|
|
||||||
command: cargo build
|
|
||||||
fourfive:
|
|
||||||
docker:
|
|
||||||
- image: circleci/rust:1.45.0
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run:
|
|
||||||
name: build and test
|
|
||||||
command: cargo build
|
|
||||||
fourfour:
|
|
||||||
docker:
|
|
||||||
- image: circleci/rust:1.44.0
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run:
|
|
||||||
name: build and test
|
|
||||||
command: cargo build
|
|
||||||
fourthree:
|
|
||||||
docker:
|
|
||||||
- image: circleci/rust:1.43.0
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run:
|
|
||||||
name: build and test
|
|
||||||
command: cargo build
|
|
||||||
fourtwo:
|
|
||||||
docker:
|
|
||||||
- image: circleci/rust:1.42.0
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run:
|
|
||||||
name: build and test
|
|
||||||
command: cargo build
|
|
||||||
fourone:
|
|
||||||
docker:
|
|
||||||
- image: circleci/rust:1.40.0
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run:
|
|
||||||
name: build and test
|
|
||||||
command: cargo build
|
|
||||||
fourzero:
|
|
||||||
docker:
|
|
||||||
- image: circleci/rust:1.40.0
|
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
|
@ -93,15 +29,7 @@ workflows:
|
||||||
version: 2
|
version: 2
|
||||||
build_and_test:
|
build_and_test:
|
||||||
jobs:
|
jobs:
|
||||||
- latest
|
- 1dot64
|
||||||
- fournine
|
- 1dot63
|
||||||
- foureight
|
- 1dot62
|
||||||
- fourseven
|
|
||||||
- foursix
|
|
||||||
- fourfive
|
|
||||||
- fourfour
|
|
||||||
- fourthree
|
|
||||||
- fourtwo
|
|
||||||
- fourone
|
|
||||||
- fourzero
|
|
||||||
|
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@
|
||||||
*/target
|
*/target
|
||||||
example/**/*.rs.bk
|
example/**/*.rs.bk
|
||||||
example/Cargo.lock
|
example/Cargo.lock
|
||||||
|
.idea/
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "mpu6050"
|
name = "mpu6050"
|
||||||
version = "0.1.4"
|
version = "0.1.6"
|
||||||
authors = ["Julian Gaal <gjulian@uos.de>"]
|
authors = ["Julian Gaal <gjulian@uos.de>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
@ -11,13 +11,13 @@ keywords = ["mpu6050", "imu", "embedded"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embedded-hal = "0.2.4"
|
embedded-hal = "1"
|
||||||
libm = "0.2.1"
|
libm = "0.2.1"
|
||||||
|
|
||||||
[dependencies.nalgebra]
|
[dependencies.nalgebra]
|
||||||
default-features = false
|
default-features = false
|
||||||
version = "0.24.1"
|
version = "0.31.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
i2cdev = "0.4.4"
|
i2cdev = "0.5.1"
|
||||||
linux-embedded-hal = "0.3.0"
|
linux-embedded-hal = "0.3.2"
|
||||||
|
|
18
src/lib.rs
18
src/lib.rs
|
@ -12,7 +12,7 @@
|
||||||
//! **More Examples** can be found [here](https://github.com/juliangaal/mpu6050/tree/master/examples).
|
//! **More Examples** can be found [here](https://github.com/juliangaal/mpu6050/tree/master/examples).
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use mpu6050::*;
|
//! use mpu6050::*;
|
||||||
//! use linux_embedded_hal::{I2cdev, Delay};
|
//! use linux_embedded_hal::{I2cdev, DelayNs};
|
||||||
//! use i2cdev::linux::LinuxI2CError;
|
//! use i2cdev::linux::LinuxI2CError;
|
||||||
//!
|
//!
|
||||||
//! fn main() -> Result<(), Mpu6050Error<LinuxI2CError>> {
|
//! fn main() -> Result<(), Mpu6050Error<LinuxI2CError>> {
|
||||||
|
@ -53,9 +53,9 @@ use crate::device::*;
|
||||||
use libm::{powf, atan2f, sqrtf};
|
use libm::{powf, atan2f, sqrtf};
|
||||||
use nalgebra::{Vector3, Vector2};
|
use nalgebra::{Vector3, Vector2};
|
||||||
use embedded_hal::{
|
use embedded_hal::{
|
||||||
blocking::delay::DelayMs,
|
i2c::I2c
|
||||||
blocking::i2c::{Write, WriteRead},
|
|
||||||
};
|
};
|
||||||
|
use embedded_hal::delay::DelayNs;
|
||||||
|
|
||||||
/// PI, f32
|
/// PI, f32
|
||||||
pub const PI: f32 = core::f32::consts::PI;
|
pub const PI: f32 = core::f32::consts::PI;
|
||||||
|
@ -83,7 +83,7 @@ pub struct Mpu6050<I> {
|
||||||
|
|
||||||
impl<I, E> Mpu6050<I>
|
impl<I, E> Mpu6050<I>
|
||||||
where
|
where
|
||||||
I: Write<Error = E> + WriteRead<Error = E>,
|
I: I2c<Error = E>,
|
||||||
{
|
{
|
||||||
/// Side effect free constructor with default sensitivies, no calibration
|
/// Side effect free constructor with default sensitivies, no calibration
|
||||||
pub fn new(i2c: I) -> Self {
|
pub fn new(i2c: I) -> Self {
|
||||||
|
@ -126,11 +126,11 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wakes MPU6050 with all sensors enabled (default)
|
/// Wakes MPU6050 with all sensors enabled (default)
|
||||||
fn wake<D: DelayMs<u8>>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
fn wake<D: DelayNs>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
||||||
// MPU6050 has sleep enabled by default -> set bit 0 to wake
|
// MPU6050 has sleep enabled by default -> set bit 0 to wake
|
||||||
// Set clock source to be PLL with x-axis gyroscope reference, bits 2:0 = 001 (See Register Map )
|
// Set clock source to be PLL with x-axis gyroscope reference, bits 2:0 = 001 (See Register Map )
|
||||||
self.write_byte(PWR_MGMT_1::ADDR, 0x01)?;
|
self.write_byte(PWR_MGMT_1::ADDR, 0x01)?;
|
||||||
delay.delay_ms(100u8);
|
delay.delay_ms(100);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Init wakes MPU6050 and verifies register addr, e.g. in i2c
|
/// Init wakes MPU6050 and verifies register addr, e.g. in i2c
|
||||||
pub fn init<D: DelayMs<u8>>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
pub fn init<D: DelayNs>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
||||||
self.wake(delay)?;
|
self.wake(delay)?;
|
||||||
self.verify()?;
|
self.verify()?;
|
||||||
self.set_accel_range(AccelRange::G2)?;
|
self.set_accel_range(AccelRange::G2)?;
|
||||||
|
@ -253,9 +253,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// reset device
|
/// reset device
|
||||||
pub fn reset_device<D: DelayMs<u8>>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
pub fn reset_device<D: DelayNs>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> {
|
||||||
self.write_bit(PWR_MGMT_1::ADDR, PWR_MGMT_1::DEVICE_RESET, true)?;
|
self.write_bit(PWR_MGMT_1::ADDR, PWR_MGMT_1::DEVICE_RESET, true)?;
|
||||||
delay.delay_ms(100u8);
|
delay.delay_ms(100);
|
||||||
// Note: Reset sets sleep to true! Section register map: resets PWR_MGMT to 0x40
|
// Note: Reset sets sleep to true! Section register map: resets PWR_MGMT to 0x40
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue