Skip to content

Commit

Permalink
fix: rustfmt and clippy warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Lachezar Lechev <elpiel93@gmail.com>
  • Loading branch information
elpiel committed Jan 24, 2024
1 parent a9585f3 commit b75ffdd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/calibrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ fn main() {
let dev = I2cdev::new("/dev/i2c-0").unwrap();
let mut delay = Delay {};
let mut imu = Bno055::new(dev).with_alternative_address();
imu.init(&mut delay).expect("An error occurred while building the IMU");
imu.init(&mut delay)
.expect("An error occurred while building the IMU");

imu.set_mode(BNO055OperationMode::NDOF, &mut delay)
.expect("An error occurred while setting the IMU mode");
Expand Down
7 changes: 7 additions & 0 deletions src/acc_config.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use num_derive::FromPrimitive;
use num_traits::FromPrimitive;

#[allow(clippy::unusual_byte_groupings)]
const ACC_G_RANGE_MASK: u8 = 0b000_000_11;
#[allow(clippy::unusual_byte_groupings)]
const ACC_BANDWIDTH_MASK: u8 = 0b000_111_00;
#[allow(clippy::unusual_byte_groupings)]
const ACC_OPERATION_MODE_MASK: u8 = 0b111_000_00;

#[derive(Debug)]
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
#[allow(clippy::enum_variant_names)]
pub enum Error {
BadAccGRange,
BadAccBandwidth,
Expand All @@ -16,6 +20,7 @@ pub enum Error {
#[derive(Debug, Clone, Copy, FromPrimitive)]
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
#[repr(u8)]
#[allow(clippy::unusual_byte_groupings)]
pub enum AccGRange {
G2 = 0b000_000_00,
G4 = 0b000_000_01,
Expand All @@ -26,6 +31,7 @@ pub enum AccGRange {
#[derive(Debug, Clone, Copy, FromPrimitive)]
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
#[repr(u8)]
#[allow(clippy::unusual_byte_groupings)]
pub enum AccBandwidth {
Hz7_81 = 0b000_000_00,
Hz15_63 = 0b000_001_00,
Expand All @@ -40,6 +46,7 @@ pub enum AccBandwidth {
#[derive(Debug, Clone, Copy, FromPrimitive)]
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
#[repr(u8)]
#[allow(clippy::unusual_byte_groupings)]
pub enum AccOperationMode {
Normal = 0b000_000_00,
Suspend = 0b001_000_00,
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![doc(html_root_url = "https://docs.rs/bno055/0.3.3")]
#![cfg_attr(not(feature = "std"), no_std)]

///! Bosch Sensortec BNO055 9-axis IMU sensor driver.
///! Datasheet: https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BNO055-DS000.pdf
//! Bosch Sensortec BNO055 9-axis IMU sensor driver.
//! Datasheet: https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BNO055-DS000.pdf
use embedded_hal::{
delay::DelayNs,
i2c::{I2c, SevenBitAddress},
Expand Down Expand Up @@ -668,6 +668,7 @@ bitflags! {
}
}

#[allow(clippy::misnamed_getters)]
impl AxisRemap {
pub fn x(&self) -> BNO055AxisConfig {
self.x
Expand Down Expand Up @@ -762,6 +763,7 @@ impl AxisRemapBuilder {
self.remap.x == self.remap.y || self.remap.y == self.remap.z || self.remap.z == self.remap.x
}

#[allow(clippy::result_unit_err)]
pub fn build(self) -> Result<AxisRemap, ()> {
if self.is_invalid() {
Err(())
Expand Down

0 comments on commit b75ffdd

Please sign in to comment.