Compare commits
No commits in common. "32604cc16c6a604fd0a4a35bf66bd9df800da18e" and "11554dee667f0002021cddcbfd4a34ca6179378d" have entirely different histories.
32604cc16c
...
11554dee66
4 changed files with 95 additions and 24 deletions
|
@ -1,24 +1,88 @@
|
|||
version: 2
|
||||
jobs:
|
||||
1dot64:
|
||||
latest:
|
||||
docker:
|
||||
- image: cimg/rust:1.64.0
|
||||
- image: circleci/rust:latest
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: build and test
|
||||
command: cargo build
|
||||
1dot63:
|
||||
fournine:
|
||||
docker:
|
||||
- image: cimg/rust:1.63.0
|
||||
- image: circleci/rust:1.49.0
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: build and test
|
||||
command: cargo build
|
||||
1dot62:
|
||||
foureight:
|
||||
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:
|
||||
- checkout
|
||||
- run:
|
||||
|
@ -29,7 +93,15 @@ workflows:
|
|||
version: 2
|
||||
build_and_test:
|
||||
jobs:
|
||||
- 1dot64
|
||||
- 1dot63
|
||||
- 1dot62
|
||||
- latest
|
||||
- fournine
|
||||
- foureight
|
||||
- fourseven
|
||||
- foursix
|
||||
- fourfive
|
||||
- fourfour
|
||||
- fourthree
|
||||
- fourtwo
|
||||
- fourone
|
||||
- fourzero
|
||||
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,7 +2,6 @@
|
|||
*/target
|
||||
example/**/*.rs.bk
|
||||
example/Cargo.lock
|
||||
.idea/
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
.DS_Store
|
||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "mpu6050"
|
||||
version = "0.1.6"
|
||||
version = "0.1.4"
|
||||
authors = ["Julian Gaal <gjulian@uos.de>"]
|
||||
edition = "2018"
|
||||
|
||||
|
@ -11,13 +11,13 @@ keywords = ["mpu6050", "imu", "embedded"]
|
|||
license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
embedded-hal = "1"
|
||||
embedded-hal = "0.2.4"
|
||||
libm = "0.2.1"
|
||||
|
||||
[dependencies.nalgebra]
|
||||
default-features = false
|
||||
version = "0.31.2"
|
||||
version = "0.24.1"
|
||||
|
||||
[dev-dependencies]
|
||||
i2cdev = "0.5.1"
|
||||
linux-embedded-hal = "0.3.2"
|
||||
i2cdev = "0.4.4"
|
||||
linux-embedded-hal = "0.3.0"
|
||||
|
|
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).
|
||||
//! ```no_run
|
||||
//! use mpu6050::*;
|
||||
//! use linux_embedded_hal::{I2cdev, DelayNs};
|
||||
//! use linux_embedded_hal::{I2cdev, Delay};
|
||||
//! use i2cdev::linux::LinuxI2CError;
|
||||
//!
|
||||
//! fn main() -> Result<(), Mpu6050Error<LinuxI2CError>> {
|
||||
|
@ -53,9 +53,9 @@ use crate::device::*;
|
|||
use libm::{powf, atan2f, sqrtf};
|
||||
use nalgebra::{Vector3, Vector2};
|
||||
use embedded_hal::{
|
||||
i2c::I2c
|
||||
blocking::delay::DelayMs,
|
||||
blocking::i2c::{Write, WriteRead},
|
||||
};
|
||||
use embedded_hal::delay::DelayNs;
|
||||
|
||||
/// PI, f32
|
||||
pub const PI: f32 = core::f32::consts::PI;
|
||||
|
@ -83,7 +83,7 @@ pub struct Mpu6050<I> {
|
|||
|
||||
impl<I, E> Mpu6050<I>
|
||||
where
|
||||
I: I2c<Error = E>,
|
||||
I: Write<Error = E> + WriteRead<Error = E>,
|
||||
{
|
||||
/// Side effect free constructor with default sensitivies, no calibration
|
||||
pub fn new(i2c: I) -> Self {
|
||||
|
@ -126,11 +126,11 @@ where
|
|||
}
|
||||
|
||||
/// 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
|
||||
// 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)?;
|
||||
delay.delay_ms(100);
|
||||
delay.delay_ms(100u8);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ where
|
|||
}
|
||||
|
||||
/// 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.verify()?;
|
||||
self.set_accel_range(AccelRange::G2)?;
|
||||
|
@ -253,9 +253,9 @@ where
|
|||
}
|
||||
|
||||
/// 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)?;
|
||||
delay.delay_ms(100);
|
||||
delay.delay_ms(100u8);
|
||||
// Note: Reset sets sleep to true! Section register map: resets PWR_MGMT to 0x40
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue