diff --git a/examples/nunchuck.rs b/examples/nunchuck.rs index 50f5e980..9af0242c 100644 --- a/examples/nunchuck.rs +++ b/examples/nunchuck.rs @@ -58,13 +58,13 @@ mod nunchuck { #[derive(Debug)] pub struct NunchuckReading { - joystick_x: u8, - joystick_y: u8, - accel_x: u16, // 10-bit - accel_y: u16, // 10-bit - accel_z: u16, // 10-bit - c_button_pressed: bool, - z_button_pressed: bool, + pub joystick_x: u8, + pub joystick_y: u8, + pub accel_x: u16, // 10-bit + pub accel_y: u16, // 10-bit + pub accel_z: u16, // 10-bit + pub c_button_pressed: bool, + pub z_button_pressed: bool, } impl NunchuckReading { diff --git a/examples/sensors.rs b/examples/sensors.rs index a9f3f7ba..4fc9c0cb 100644 --- a/examples/sensors.rs +++ b/examples/sensors.rs @@ -285,9 +285,8 @@ mod sensors { // If values are less than 16 bytes, need to adjust let extrabits = 16 - integer_bits - fractional_bits - 1; let rawval: i16 = BigEndian::read_i16(&[msb, lsb]); - let adj = (f32::from(rawval) / 2_f32.powi(fractional_bits + extrabits)) - / 10_f32.powi(dec_pt_zero_pad); - adj + (f32::from(rawval) / 2_f32.powi(fractional_bits + extrabits)) + / 10_f32.powi(dec_pt_zero_pad) } impl MPL115A2Coefficients { diff --git a/src/ffi.rs b/src/ffi.rs index 3fadd70b..aaab92c2 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -354,7 +354,7 @@ pub fn i2c_smbus_read_block_data(fd: RawFd, register: u8) -> Result, I2C // create a vector from the data in the block starting at byte // 1 and ending after count bytes after that let count = data.block[0]; - Ok((&data.block[1..(count + 1) as usize]).to_vec()) + Ok((data.block[1..(count + 1) as usize]).to_vec()) } pub fn i2c_smbus_read_i2c_block_data( @@ -377,7 +377,7 @@ pub fn i2c_smbus_read_i2c_block_data( // create a vector from the data in the block starting at byte // 1 and ending after count bytes after that let count = data.block[0]; - Ok((&data.block[1..(count + 1) as usize]).to_vec()) + Ok((data.block[1..(count + 1) as usize]).to_vec()) } #[inline] @@ -445,7 +445,7 @@ pub fn i2c_smbus_process_call_block( // create a vector from the data in the block starting at byte // 1 and ending after count bytes after that let count = data.block[0]; - Ok((&data.block[1..(count + 1) as usize]).to_vec()) + Ok((data.block[1..(count + 1) as usize]).to_vec()) } #[inline] diff --git a/src/linux.rs b/src/linux.rs index 18cbb180..4e855037 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -301,7 +301,7 @@ impl<'a> I2CTransfer<'a> for LinuxI2CDevice { /// Issue the provided sequence of I2C transactions fn transfer(&mut self, messages: &'a mut [Self::Message]) -> Result { for msg in messages.iter_mut() { - (*msg).addr = self.slave_address; + msg.addr = self.slave_address; } ffi::i2c_rdwr(self.as_raw_fd(), messages).map_err(From::from) }