1
Fork 0

Compare commits

..

No commits in common. "32604cc16c6a604fd0a4a35bf66bd9df800da18e" and "11554dee667f0002021cddcbfd4a34ca6179378d" have entirely different histories.

4 changed files with 95 additions and 24 deletions

View file

@ -1,24 +1,88 @@
version: 2 version: 2
jobs: jobs:
1dot64: latest:
docker: docker:
- image: cimg/rust:1.64.0 - image: circleci/rust:latest
steps: steps:
- checkout - checkout
- run: - run:
name: build and test name: build and test
command: cargo build command: cargo build
1dot63: fournine:
docker: docker:
- image: cimg/rust:1.63.0 - image: circleci/rust:1.49.0
steps: steps:
- checkout - checkout
- run: - run:
name: build and test name: build and test
command: cargo build command: cargo build
1dot62: foureight:
docker: docker:
- image: cimg/rust:1.62.0 - image: circleci/rust:1.48.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:
@ -29,7 +93,15 @@ workflows:
version: 2 version: 2
build_and_test: build_and_test:
jobs: jobs:
- 1dot64 - latest
- 1dot63 - fournine
- 1dot62 - foureight
- fourseven
- foursix
- fourfive
- fourfour
- fourthree
- fourtwo
- fourone
- fourzero

1
.gitignore vendored
View file

@ -2,7 +2,6 @@
*/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

View file

@ -1,6 +1,6 @@
[package] [package]
name = "mpu6050" name = "mpu6050"
version = "0.1.6" version = "0.1.4"
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 = "1" embedded-hal = "0.2.4"
libm = "0.2.1" libm = "0.2.1"
[dependencies.nalgebra] [dependencies.nalgebra]
default-features = false default-features = false
version = "0.31.2" version = "0.24.1"
[dev-dependencies] [dev-dependencies]
i2cdev = "0.5.1" i2cdev = "0.4.4"
linux-embedded-hal = "0.3.2" linux-embedded-hal = "0.3.0"

View file

@ -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, DelayNs}; //! use linux_embedded_hal::{I2cdev, Delay};
//! 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::{
i2c::I2c blocking::delay::DelayMs,
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: I2c<Error = E>, I: Write<Error = E> + WriteRead<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: DelayNs>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> { fn wake<D: DelayMs<u8>>(&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(100); delay.delay_ms(100u8);
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: DelayNs>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> { pub fn init<D: DelayMs<u8>>(&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: DelayNs>(&mut self, delay: &mut D) -> Result<(), Mpu6050Error<E>> { pub fn reset_device<D: DelayMs<u8>>(&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(100); delay.delay_ms(100u8);
// 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(())
} }