1
Fork 0

Compare commits

...

10 commits

Author SHA1 Message Date
32604cc16c
bump embedded_hal to 1.0 2025-01-04 16:33:33 -05:00
juliangaal
aeb0e91bc7 bump linux-embedded-hal to make examples compile 2022-12-04 15:26:11 +01:00
Julian Gaal
d948e4e16c bump crate version: upgrade i2cdev, nalgebra 2022-11-03 23:13:27 +01:00
Julian Gaal
d76cedddbc
Merge pull request #43 from juliangaal/dependabot/cargo/i2cdev-0.5.1
Update i2cdev requirement from 0.4.4 to 0.5.1
2022-11-02 23:34:23 +01:00
dependabot[bot]
c29d609545
Update i2cdev requirement from 0.4.4 to 0.5.1
Updates the requirements on [i2cdev](https://github.com/rust-embedded/rust-i2cdev) to permit the latest version.
- [Release notes](https://github.com/rust-embedded/rust-i2cdev/releases)
- [Changelog](https://github.com/rust-embedded/rust-i2cdev/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-embedded/rust-i2cdev/compare/0.4.4...0.5.1)

---
updated-dependencies:
- dependency-name: i2cdev
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-29 18:03:12 +00:00
Julian Gaal
17c9a709d2
Merge pull request #52 from juliangaal/dependabot/cargo/nalgebra-0.31.2
Update nalgebra requirement from 0.24.1 to 0.31.2
2022-10-29 20:01:57 +02:00
juliangaal
4841c079b6 use 2022 compilers for circleci 2022-10-29 19:59:01 +02:00
juliangaal
f54d41e6ed move to new circle ci images 2022-10-29 19:54:06 +02:00
dependabot[bot]
409fcf0cd1
Update nalgebra requirement from 0.24.1 to 0.31.2
Updates the requirements on [nalgebra](https://github.com/dimforge/nalgebra) to permit the latest version.
- [Release notes](https://github.com/dimforge/nalgebra/releases)
- [Changelog](https://github.com/dimforge/nalgebra/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/dimforge/nalgebra/compare/v0.24.1...v0.31.2)

---
updated-dependencies:
- dependency-name: nalgebra
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 20:15:12 +00:00
juliangaal
22307711cc new version tag 2022-01-10 12:38:14 +01:00
4 changed files with 24 additions and 95 deletions

View file

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

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
*/target
example/**/*.rs.bk
example/Cargo.lock
.idea/
**/*.rs.bk
Cargo.lock
.DS_Store

View file

@ -1,6 +1,6 @@
[package]
name = "mpu6050"
version = "0.1.4"
version = "0.1.6"
authors = ["Julian Gaal <gjulian@uos.de>"]
edition = "2018"
@ -11,13 +11,13 @@ keywords = ["mpu6050", "imu", "embedded"]
license = "MIT"
[dependencies]
embedded-hal = "0.2.4"
embedded-hal = "1"
libm = "0.2.1"
[dependencies.nalgebra]
default-features = false
version = "0.24.1"
version = "0.31.2"
[dev-dependencies]
i2cdev = "0.4.4"
linux-embedded-hal = "0.3.0"
i2cdev = "0.5.1"
linux-embedded-hal = "0.3.2"

View file

@ -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, Delay};
//! use linux_embedded_hal::{I2cdev, DelayNs};
//! 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::{
blocking::delay::DelayMs,
blocking::i2c::{Write, WriteRead},
i2c::I2c
};
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: Write<Error = E> + WriteRead<Error = E>,
I: I2c<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: 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
// 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(100u8);
delay.delay_ms(100);
Ok(())
}
@ -154,7 +154,7 @@ where
}
/// 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.verify()?;
self.set_accel_range(AccelRange::G2)?;
@ -253,9 +253,9 @@ where
}
/// 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)?;
delay.delay_ms(100u8);
delay.delay_ms(100);
// Note: Reset sets sleep to true! Section register map: resets PWR_MGMT to 0x40
Ok(())
}